@dashdoc/ react-native-系统声音
一个用于在iOS和Android上播放系统声音和蜂鸣的React Introduct(无声音文件)模块.
灵感来自 反应 - 内生 - 蜂鸣
与该建筑 展览模块 API
安装
安装 Expo 模块自动链接
- 从 npm 安装软件包
yarn add @dashdoc/react-native-system-sounds
-
请在您的应用程序中安装 Expo 模块 。 博览会的应用已经包括了它们. 在赤裸的回放原生应用程序中,跟随博览会 安装 Expo 模块指南。 。 。 .
-
安装 iOS 选项
cd ios && pod install && cd ..
使用量
import RNSystemSounds from '@dashdoc/react-native-system-sounds';
// ...
<Button
title="Play positive beep"
onPress={() => RNSystemSounds.beep()}
/>
<Button
title="Play negative beep"
onPress={() => RNSystemSounds.beep(RNSystemSounds.Beeps.Negative)}
/>
<Button
title="Play custom system sound"
onPress={() =>
RNSystemSounds.play(
Platform.select({
android: RNSystemSounds.AndroidSoundIDs.TONE_CDMA_ABBR_ALERT,
ios: RNSystemSounds.iOSSoundIDs.AudioToneBusy,
})
)
}
/>
示例
- 清除仓库, 输入
example目录并安装依赖.
git clone [email protected]:dashdoc/react-native-system-sounds.git
cd example/
yarn install
- 安装 iOS Pods,
cd ios && pod install && cd ..
- 开始捆绑.
yarn start
- 在新的终端上运行应用程序
<platform>由你选择(ios或者说android) (中文(简体) ).
cd example/
yarn <platform>