没有声音来自AVPlayer
我试图用AVPlayer播放mp3(相机快门声)。 我已经把所有东西都分解成了一个简单的button,当按下它时,播放声音。 所有的对象正在创build正确的,但是当我运行我的iPhone或iPad(都运行iOS 6)的应用程序没有声音产生。 不,静音button不亮,音量调大。 :)我可以听到两个设备上的其他应用程序的声音。
我在做什么愚蠢的事情?
- (void)playCameraShutterSound { NSURL *url = [[NSBundle mainBundle] URLForResource:@"Grab" withExtension:@"mp3" ]; AVPlayer* player = [AVPlayer playerWithURL:url]; [player play]; }
“玩家”被释放方法的结束。 它必须被保留为一个类variables。
尝试这些行,并用您的文件名replace“yoursound.mp3”:
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/yoursound.mp3", [[NSBundle mainBundle] resourcePath]]]; AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil]; AVPlayerItem *anItem = [AVPlayerItem playerItemWithAsset:asset]; avplayer = [AVPlayer playerWithPlayerItem:anItem]; [avplayer play];
- 如何在iPhone上录制AMRaudio格式?
- Android和iOS有什么共同的audio格式编码器?
- 如何使用kAudioSessionProperty_OverrideCategoryMixWithOthers
- 为什么这个audio会话无法识别中断?
- 在button上播放声音(AVaudio播放器)返回零string参数
- 从Swift应用程序发送audio到PHP服务器,以及audio丢失的地方
- 用AVAssetReader和timeRange实时读取样本
- iOS应用程序不会死亡,写入控制台并退出后播放声音
- 适用于iOS的kAudioDevicePropertyBufferFrameSizereplace