EXC_BAD_ACCESS 使用 MPMoviePlayerViewController
EXC_BAD_ACCESS using MPMoviePlayerViewController
我正在使用 MPMoviePlayerViewController 从服务器播放视频。
@property (strong, nonatomic) MPMoviePlayerViewController *videoPlayer;
当我重新启动视频时,我得到 EXC_BAD_ACCESS
(代码=1,地址=0xc000000c)...
_videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[NSString ... ]]];
[self presentMoviePlayerViewControllerAnimated:_videoPlayer];
我该如何解决?
我确实用它作为礼物..
但你可以--
导入媒体播放器框架
在你的 .h
MPMoviePlayerController *moviePlayerController;
NSString *strVideoURL;
在你的.m
在您的 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];
或任何您想播放、暂停、停止或重新开始的地方
经过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];
}
就这些!
我正在使用 MPMoviePlayerViewController 从服务器播放视频。
@property (strong, nonatomic) MPMoviePlayerViewController *videoPlayer;
当我重新启动视频时,我得到 EXC_BAD_ACCESS
(代码=1,地址=0xc000000c)...
_videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[NSString ... ]]];
[self presentMoviePlayerViewControllerAnimated:_videoPlayer];
我该如何解决?
我确实用它作为礼物..
但你可以--
导入媒体播放器框架 在你的 .h
MPMoviePlayerController *moviePlayerController; NSString *strVideoURL;
在你的.m
在您的 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];
或任何您想播放、暂停、停止或重新开始的地方
经过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];
}
就这些!