我从资源获取网址并尝试播放所选视频。但是MPMoviePlayer
没有显示任何内容
NSString* urlStr = @"assets-library://asset/asset.mp4?id=0685B109-8699-410D-8775-140972AF8397&ext=mp4";
NSURL* movieUrl = [[NSURL alloc] initWithString:urlStr];
MPMoviePlayerController* player = [[MPMoviePlayerController alloc] init];
[player view].backgroundColor = [UIColor clearColor];
player.scalingMode = MPMovieScalingModeNone;
player.controlStyle = MPMovieControlModeDefault;
player.backgroundView.backgroundColor = [UIColor clearColor];
player.repeatMode = MPMovieRepeatModeNone;
[player setContentURL:movieUrl];
[self.view addSubview:player.view];
[player setFullscreen:YES animated:YES];
[player play];
我进入控制台:
[MPAVController] Autoplay: Disabling autoplay for pause
2013-12-11 15:47:17.575 XavBookXavient[74716:c07] [MPAVController] Autoplay: Disabling autoplay
2013-12-11 15:47:17.583 XavBookXavient[74716:c07] [MPAVController] Autoplay: Disabling autoplay for pause
2013-12-11 15:47:17.583 XavBookXavient[74716:c07] [MPAVController] Autoplay: Disabling autoplay
2013-12-11 15:47:17.587 XavBookXavient[74716:c07] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)
答案 0 :(得分:0)
尝试调用以下方法。
[player prepareToPlay];
调用“prepareToPlay”修复了你的问题,没有它,“MPMoviePlayerLoadStateDidChangeNotification”没有被发送,因为播放器没有费心预加载视频。