Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要使用AVAudioPlayer iOS从URL流式传输音频的帮助吗_Ios_Xcode_Audio_Stream_Avaudioplayer - Fatal编程技术网

需要使用AVAudioPlayer iOS从URL流式传输音频的帮助吗

需要使用AVAudioPlayer iOS从URL流式传输音频的帮助吗,ios,xcode,audio,stream,avaudioplayer,Ios,Xcode,Audio,Stream,Avaudioplayer,我正在使用twilio创建一个手机应用程序。我有一个指向语音邮件的链接,我正在尝试从tableview中的控件播放语音邮件。因为我从来没有流式音频之前,我决定简化一切,只是尝试流式音频从任何网址。我试图从中流式传输音频的URL为“” 我尝试过使用苹果开发者页面上的例子,但我想我只是不理解文档 这是我目前正在尝试的,我得到了一个错误 NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbo

我正在使用twilio创建一个手机应用程序。我有一个指向语音邮件的链接,我正在尝试从tableview中的控件播放语音邮件。因为我从来没有流式音频之前,我决定简化一切,只是尝试流式音频从任何网址。我试图从中流式传输音频的URL为“”

我尝试过使用苹果开发者页面上的例子,但我想我只是不理解文档

这是我目前正在尝试的,我得到了一个错误

NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
NSError *error;
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
我得到了这个错误

Error Domain=NSOSStatusErrorDomain Code=2003334207 "The operation couldn’t be completed. (OSStatus error 2003334207.)"
我是朝着正确的方向走,还是应该做些不同的事情。我发现了许多不同的线索,但我看到的都不能让我播放音频。如果能朝着正确的方向努力,我们将不胜感激

我也尝试过使用AVPlayer

NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
self.player = [[AVPlayer alloc] initWithURL:url];
[self.player play];
什么也没发生

试试这个

@property (nonatomic,strong) AVPlayer *audioStremarPlayer;

NSURL *url = [NSURL URLWithString:@"your url"];

// stremar player
AVPlayer *player = [[AVPlayer alloc]initWithURL:url];
self.audioStremarPlayer= player;
[self.audioStremarPlayer addObserver:self forKeyPath:@"status" options:0 context:nil];

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 
{

    if (object == self.audioStremarPlayer && [keyPath isEqualToString:@"status"]) {
        if (self.audioStremarPlayer.status == AVPlayerStatusFailed)
        {
      //  //NSLog(@"AVPlayer Failed");
        } 
        else if (self.audioStremarPlayer.status == AVPlayerStatusReadyToPlay) 
        {
            [self.audioStremarPlayer play];
        } 
        else if (self.audioStremarPlayer.status == AVPlayerItemStatusUnknown) 
        {
      //  //NSLog(@"AVPlayer Unknown");

        }
    }
}   
可能的副本: