[英]iPhone SDK: Stopping a Video
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];
}
theMovie
instance var theMovie
实例变 -(void) viewWillDisappear:(BOOL)animated
-(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
或将此代码移动到
-(void) viewDidAppear:(BOOL)animated
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.