【发布时间】:2014-02-01 23:04:03
【问题描述】:
我正在制作一个即使 iPhone 处于静音模式也需要播放声音的应用程序,但是使用我现在拥有的代码(查看这篇文章的底部),如果 iPhone 处于静音模式,它不会播放声音.
我正在使用以下代码:
Viewcontroller.h:
@interface SoundViewController : UIViewController <UICollectionViewDataSource, UIApplicationDelegate, AVAudioPlayerDelegate, ADBannerViewDelegate, UIActionSheetDelegate> {
SystemSoundID SoundID;
NSString *listPath;
}
ViewController.m:
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (__bridge CFStringRef) [mainArray objectAtIndex:indexPath.row], CFSTR("wav"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
【问题讨论】:
标签: ios iphone objective-c audio