如何从头开始停止MPMoviePlayerViewController

时间:2016-01-20 09:39:28

标签: ios objective-c mpmovieplayer

我想在iOS应用程序中转到下一个ViewController时播放电影。

我写了这封电话。

SELECT *
FROM test
ORDER BY substring(NAME FROM '[$&+,:;=?@#|]') -- To get special character
        ,substring(NAME FROM '^[0-9]*$')::INT -- To get only integer from a value(87 and 123)
        ,substring(NAME FROM '[0-9]+')::INT   -- To get integer from a value (10 from G10) 

但是当ViewController出现并从头开始播放时,电影不会停止(暂停)。 (当我触摸视图时,电影暂停了。一旦我触摸那里,电影再次播放)

我应该怎样做才能从一开始就停止电影?

1 个答案:

答案 0 :(得分:0)

MPMPlayerController有默认属性“ shouldAutoplay

用户以下代码::

MPMPlayerController = [[MPMoviePlayerViewController alloc]initWithContentURL:filePath ];
MPMPlayerController.moviePlayer.backgroundView.backgroundColor = [UIColor clearColor];
MPMPlayerController.moviePlayer.controlStyle = MPMovieControlStyleNone;
//MPMPlayerController.view.frame = self.view.frame;
MPMPlayerController.view.frame = CGRectMake(0, 0, 320, 600);

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(splashMoviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:nil];

[[NSNotificationCenter defaultCenter] removeObserver:MPMPlayerController
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:MPMPlayerController.moviePlayer];

MPMPlayerController.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[MPMPlayerController.moviePlayer setFullscreen:YES animated:NO];

//*** Change
[MPMPlayerController.moviePlayer setShouldAutoplay:NO]
//***

[self.view addSubview:MPMPlayerController.view];

[MPMPlayerController.moviePlayer pause];