1
我想從服務器播放TS文件:AVPlayer播放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
}
}
}
而且玩家無法播放該文件。 我檢查文件是否可以在我的瀏覽器中下載,並且工作完美。 任何想法如何解決它?