0

我整天都在尝试,但由于某种原因,我在 IOS6 上遇到了 MPMoviePlayerController 的很多问题,似乎人们遇到了问题,但与我的不够相似:

当电影完成时,电影加载并播放正常。我可以循环播放电影。当我尝试像这样关闭并删除电影时出现问题:

如果我将控件添加到电影本身并点击“完成”按钮,电影就会暂停并且永远不会关闭!

任何提示/想法?

_moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

[[NSNotificationCenter defaultCenter] addObserver:self  
                                         selector:@selector(moviePlaybackComplete:)  
                                             name:MPMoviePlayerPlaybackDidFinishNotification  
                                           object:_moviePlayerController];  

[[NSNotificationCenter defaultCenter] addObserver:self  
                                         selector:@selector(moviePlaybackLoaded:)  
                                             name:MPMoviePlayerLoadStateDidChangeNotification  
                                           object:_moviePlayerController];

[[NSNotificationCenter defaultCenter] addObserver:self  
                                         selector:@selector(moviePlaybackComplete:)  
                                             name:kMovieOverlayViewTapped
                                           object:nil];


[self.view addSubview:_moviePlayerController.view];  
_moviePlayerController.fullscreen = YES;

-

现在在播放加载:

- (void)moviePlaybackLoaded:(NSNotification *)notification  
{   
    [[NSNotificationCenter defaultCenter] removeObserver:self  
                                                    name:MPMoviePlayerLoadStateDidChangeNotification  
                                                  object:_moviePlayerController]; 

_moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
_moviePlayerController.controlStyle = MPMovieControlStyleDefault;
[_moviePlayerController prepareToPlay];
[_moviePlayerController.view setFrame:CGRectMake(38, 100, 250, 163)];
[_moviePlayerController play];

}

现在删除视频:

 - (void)moviePlaybackComplete:(NSNotification *)notification  
{
    [[NSNotificationCenter defaultCenter] removeObserver:self  
                                                        name:MPMoviePlayerPlaybackDidFinishNotification  
                                                      object:_moviePlayerController];  

    [[NSNotificationCenter defaultCenter] removeObserver:self  
                                                    name:MPMoviePlayerDidExitFullscreenNotification  
                                                  object:_moviePlayerController]; 

[[NSNotificationCenter defaultCenter] removeObserver:self  
                                                    name:kMovieOverlayViewTapped
                                                  object:nil]; 

[_moviePlayerController stop];
[_moviePlayerController.view removeFromSuperview];       
    _moviePlayerController = nil;
4

0 回答 0