我正在使用MPMoviePlayerViewController从服务器播放视频。
@property (strong, nonatomic) MPMoviePlayerViewController *videoPlayer;
当我重新启动视频时,我得到EXC_BAD_ACCESS
(代码= 1,地址= 0xc000000c)......
_videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[NSString ... ]]];
[self presentMoviePlayerViewControllerAnimated:_videoPlayer];
我该如何解决?
答案 0 :(得分:0)
我确实用它作为礼物..
但你可以 -
导入mediaPlayer框架 在你的.h
MPMoviePlayerController * moviePlayerController; NSString * strVideoURL;
在ViewDidLoad中
-
NSURL *urlVideo = [NSURL URLWithString:strVideoURL];
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:urlVideo];
[moviePlayerController.view setFrame:CGRectMake(0, 170, 320, 270)]
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
或您想要播放,暂停,停止或重新启动的任何地方
答案 1 :(得分:0)
经过3天的搜索,得到了解决方案!!!
-(void)viewWillAppear:(BOOL)animated{
// just add observer
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieEventFullscreenHandler:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
}
然后我需要停止播放器然后用户按下完成:
- (IBAction) movieEventFullscreenHandler:(NSNotification*)notification{
[self.player.moviePlayer stop];
[self.player.moviePlayer setFullscreen:NO animated:NO];
}
多数民众赞成!