iphonesdk:停止视频

iphonesdk:停止视频,iphone,xcode,video,ios4,Iphone,Xcode,Video,Ios4,当我离开某个视图时,如何停止视频,并在再次回到原始视图时再次播放视频 以下是在原始视图中播放视频的代码: - (void)viewDidLoad { NSBundle *bundle=[NSBundle mainBundle]; NSString *moviePath = [bundle pathForResource:@"Video" ofType:@"mp4"]; NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] r

当我离开某个视图时,如何停止视频,并在再次回到原始视图时再次播放视频

以下是在原始视图中播放视频的代码:

- (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];      
}
  • 使移动<代码>实例变量
  • 停止在
    -(void)视图中播放将消失:(BOOL)动画
  • 当您导航回该视图时,它应该开始播放。或者将此代码移动到
    -(void)viewdide出现:(BOOL)动画