@H_301_12@
如果您正在使用音频会话,请包括< AVFoundation / AVFoundation.h>在您的文件的开始和@H_301_12@
@H_301_12@
[[AVAudioSession sharedInstance] setcategory: AVAudioSessioncategoryPlayback error: nil];
应该做的伎俩。请注意,如果您播放音乐或声音,则iPod播放将暂停。@H_301_12@
一旦这已经完成,可能在您的类之一的初始化播放声音,你可以实例化的声音,像这样:@H_301_12@
@H_301_12@
// probably an instance variable: AVAudioPlayer *player;Nsstring *path = [[NSBundle mainBundle] pathForResource...];NSURL *url = [NSURL fileURLWithPath:path];player = [[AVAudioPlayer alloc] initWithContentsOfURL:url];
完成后,您可以随时随地使用:@H_301_12@
@H_301_12@
[player play]; // Play the sound[player pause]; // Pause the sound halfway through playingplayer.currentTime += 10 // skip forward 10 secondsplayer.duration // Get the duration
和其他好东西。查找AVAudioPlayer类参考。@H_301_12@ 总结
以上是内存溢出为你收集整理的在iPhone上播放声音,即使在静音模式全部内容,希望文章能够帮你解决在iPhone上播放声音,即使在静音模式所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)