Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.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
Iphone iOS 4.0中使用AVPlayer的HTTP实时流媒体?_Iphone_Ios_Avfoundation_Avplayer_Http Live Streaming - Fatal编程技术网

Iphone iOS 4.0中使用AVPlayer的HTTP实时流媒体?

Iphone iOS 4.0中使用AVPlayer的HTTP实时流媒体?,iphone,ios,avfoundation,avplayer,http-live-streaming,Iphone,Ios,Avfoundation,Avplayer,Http Live Streaming,在iOS 4.0上是否可以将HTTP直播与AVPlayer一起使用?这显然是4.0的一个文档化特性。但是,如果我在运行iOS 4.0.1的3GS上运行,单击“加载电影”不会播放流,但会出现错误: 2011-06-21 13:14:49.428 StitchedStreamPlayer[680:307]由于以下错误,未加载资源的轨迹: 打不开 MPMediaPlayer可以在同一台设备上播放。然而,我需要一个AVPlayer的工作解决方案 有人知道如何让苹果的StichedStreamPlayer

在iOS 4.0上是否可以将HTTP直播与AVPlayer一起使用?这显然是4.0的一个文档化特性。但是,如果我在运行iOS 4.0.1的3GS上运行,单击“加载电影”不会播放流,但会出现错误:

2011-06-21 13:14:49.428 StitchedStreamPlayer[680:307]由于以下错误,未加载资源的轨迹: 打不开

MPMediaPlayer可以在同一台设备上播放。然而,我需要一个AVPlayer的工作解决方案

有人知道如何让苹果的StichedStreamPlayer代码在4.0上运行吗?运行时要求它应该在“iOS 4.0或更高版本”上运行


谢谢

这是4.0中的一个bug,但我找到了一个解决方法。以下是使用AVPlayer加载视频的正确方法:

    AVPlayer *player = [AVPlayer playerWithURL:[NSURL URLWithString:@"http://qtdevseed.apple.com/addemo/ad.m3u8"]];
// now use KVO to decide when it's ready to play
// works in both 4.3 and 4.0.1

StitchedStreamPlayer中的代码适用于4.3,但不适用于4.0.1:

AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:@"http://qtdevseed.apple.com/addemo/ad.m3u8"] options:nil];
    NSArray *tracksKeys = [NSArray arrayWithObjects:kTracksKey, kDurationKey, kPlayableKey, nil];
    [asset loadValuesAsynchronouslyForKeys:tracksKeys completionHandler:
     ^{
         NSError *error = nil;
         AVKeyValueStatus status = [asset statusOfValueForKey:[tracksKeys objectAtIndex:0] error:&error];
         NSLog(@"status=%@,error=%@",(status==AVKeyValueStatusLoaded?@"Loaded":status==AVKeyValueStatusFailed?@"Failed":@"?!"),error);
     }];

// output in 4.3: status=Loaded,error=(null)
// output in 4.0.1:  status=Failed,error=Error Domain=AVFoundationErrorDomain Code=-11828 "Cannot Open" UserInfo=0x15f2a0 {NSLocalizedFailureReason=This media format is not supported., NSUnderlyingError=0x1599e0 "The operation couldn’t be completed. (OSStatus error -12847.)", NSLocalizedDescription=Cannot Open}

有关更多信息,请参阅