我想从服务器播放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)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
}
}
}
播放器不播放该文件。 我检查文件是否可以在我的浏览器中下载并且它可以正常工作。 知道怎么解决吗?