SoundMachine:在 iOS 应用程序中播放系统声音的简单方法

  • L0_351904
  • 7MB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-04-01 01:23
音响机 在 iOS 应用程序中播放系统声音的简单方法。 这允许轻松高效地播放 .wav 文件。 设置 将 SGSoundMachine.h 和 SGSoundMachine.m 拖入您的应用程序包中 将框架 AudioToolbox 链接到您的包中 创建一个名为“Sounds”的文件夹并将其拖入您的包中。 确保选择“为任何添加的文件夹创建文件夹引用” 用法 对于要播放声音的任何地方,请导入 SGSoundMachine.h 然后调用-(void)playSoundWithName:(NSString *)soundName ,其中 soundName 是您要播放的声音的文件名。 (例如[[SGSoundMachine soundMachine] playSoundWithName:@"test"]; ) 笔记 如果要使 soundMachine 静音,请将它的soundIsOff属性设置
SoundMachine ============ A easy way to play system sounds in an iOS app. This allows for performant playing of .wav files easily. Setup ===== * Drag in SGSoundMachine.h and SGSoundMachine.m into your app bundle * Link the framework AudioToolbox into your bundle * Create a folder called "Sounds" and drag into your bundle. Make sure to select "Create folder references for any added folders" Usage ===== * For any place that you want to play a sound, import SGSoundMachine.h * Then call `-(void)playSoundWithName:(NSString *)soundName` with the soundName being the file name of the sound you want to play. (e.g. `[[SGSoundMachine soundMachine] playSoundWithName:@"test"];`) Notes ====== * If you want to mute the soundMachine, set it's `soundIsOff` property which is a `BOOL`. * To prevent any lag during the first playing of a sound, it's okay to call `[SGSoundMachine soundMachine]` at `- (void)applicationDidFinishLaunching:(UIApplication *)application`. * If you get any errors including `-1500`, the wav may not be in a format that the iOS device can handle. Try resaving in QuickTime and reimporting. Let me know if you have any feedback!