iPhone SDK:停止视频
如何在离开视图后停止视频并在再次返回原始视图时再次播放视频?
以下是在原始视图中播放视频的代码:
- (void)viewDidLoad {
NSBundle *bundle=[NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Video" ofType:@"mp4"];
NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
theMovie.view.frame = CGRectMake(104.0, 134.0, 200.0, 250.0);
[self.view addSubview:theMovie.view];
[theMovie play];
[super viewDidLoad];
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
}
How can I stop a video once I navigate away from a view and make the video play again when I get back to the original view again?
Here is the code to play the video in the original view:
- (void)viewDidLoad {
NSBundle *bundle=[NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Video" ofType:@"mp4"];
NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
theMovie.view.frame = CGRectMake(104.0, 134.0, 200.0, 250.0);
[self.view addSubview:theMovie.view];
[theMovie play];
[super viewDidLoad];
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
theMovie
实例 var-(void) viewWillDisappear:(BOOL)animated
中停止播放,当您导航回此视图时,它应该开始播放。或者将此代码移至
-(void) viewDidAppear:(BOOL)animated
theMovie
instance var-(void) viewWillDisappear:(BOOL)animated
And it should start playing when you navigate back to this view. Or move this code to
-(void) viewDidAppear:(BOOL)animated