iOS 7视频无法播放MPMoviePlayerController

时间:2015-08-21 13:22:19

标签: objective-c ios7

此代码在iOS 8中运行良好。但是无法在iOS7中播放视频。播放器显示但没有播放。谢谢

NSString *url = @"http://.../playlist.m3u8";
NSURL *streamURL = [NSURL URLWithString:url];
self.streamPlayer = [[MPMoviePlayerController alloc] initWithContentURL:streamURL];
self.streamPlayer.controlStyle= MPMovieControlStyleFullscreen;
self.streamPlayer.movieSourceType = MPMovieSourceTypeStreaming;
self.streamPlayer.shouldAutoplay = YES;
[self.view addSubview:self.streamPlayer.view];
[self.streamPlayer prepareToPlay];
[self.streamPlayer play];

1 个答案:

答案 0 :(得分:0)

来自文档:

将电影播放器​​的视图添加到应用的视图层次结构时,请务必正确调整帧的大小,如下所示:

MPMoviePlayerController *player =
        [[MPMoviePlayerController alloc] initWithContentURL: myURL];
[player prepareToPlay];
[player.view setFrame: myView.bounds];  // player's frame must match parent's
[myView addSubview: player.view];
// ...
[player play];

尝试设置视频播放器的帧。