音频播放无法开始 [英] Audio playback does not start

查看:100
本文介绍了音频播放无法开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NSError *err;

// Initialize audio player
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&err];

audioPlayer.delegate = self;
[audioPlayer play];

使用上面的代码,我试图初始化.mp3文件的播放,但是播放根本没有开始.没有声音.我究竟做错了什么?我检查了'err',那里什么也没有.

With the code above, I'm trying to initialize playback of a .mp3 file, however the playback does not start at all. There is no sound. What am I doing wrong? I have inspected 'err' and there is nothing there.

添加AVAudioSession之后,我从AVAudioPlayer收到以下错误消息

After adding AVAudioSession, I'm getting the following error from AVAudioPlayer

The operation couldn’t be completed. (OSStatus error -43.)

推荐答案

显然AVAudioPlayer不支持通过. HTTP就像我试图做的那样,因此通过使用AVPlayer使其正常运行.

Apparently AVAudioPlayer does not support streaming via. HTTP as I was trying to do, so by using AVPlayer instead, I got it working.

这篇关于音频播放无法开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆