Ios AVPlayer播放ts文件
我想通过以下方式从服务器播放ts文件:Ios AVPlayer播放ts文件,ios,iphone,objective-c,Ios,Iphone,Objective C,我想通过以下方式从服务器播放ts文件: - (void)play { NSURL *url= [NSURL URLWithString:@"http://10.0.0.18/11.ts"]; player = [[AVPlayer alloc] initWithURL:url]; [player addObserver:self forKeyPath:@"status" options:0 context:nil]; } - (void)observeValueFo
- (void)play {
NSURL *url= [NSURL URLWithString:@"http://10.0.0.18/11.ts"];
player = [[AVPlayer alloc] initWithURL:url];
[player addObserver:self forKeyPath:@"status" options:0 context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context {
if (object == player && [keyPath isEqualToString:@"status"]) {
if (player.status == AVPlayerStatusReadyToPlay) {
[player setVolume:1.0];
[player play];
} else if (player.status == AVPlayerStatusFailed) {
// something went wrong. player.error should contain some information
}
}
}
而玩家不会播放该文件。
我检查文件是否可以在我的浏览器中下载,它是否工作正常。
知道如何修复它吗?AVPlayer(也不是Apple框架中的任何类)不能播放TS文件
唯一的方法是将其放入通过本地http服务器分发的m3u8播放列表中,然后播放此播放列表。否则,必须将ts转换为mp4,请参阅或