Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 我的电影播放器对功能没有反应_Iphone_Objective C_C_Ios4 - Fatal编程技术网

Iphone 我的电影播放器对功能没有反应

Iphone 我的电影播放器对功能没有反应,iphone,objective-c,c,ios4,Iphone,Objective C,C,Ios4,我面临着内存泄漏和其他影音播放器新启动的问题,因为我的影音播放器没有响应功能,在该功能中,我在“完成”按钮上释放该播放器 (void) playMovieAtURL { MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]]; mpViewController.vi

我面临着内存泄漏和其他影音播放器新启动的问题,因为我的影音播放器没有响应功能,在该功能中,我在“完成”按钮上释放该播放器

(void) playMovieAtURL
{

    MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]];
    mpViewController.view.backgroundColor = [UIColor blackColor];
    [self presentMoviePlayerViewControllerAnimated:mpViewController];

    [mpViewController.view setCenter:self.view.center];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(myMovieFinishedCallback:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:mpViewController]; 

} 


    // When the movie is done,release the controller. (Doesn't come in it.)
-(void)myMovieFinishedCallback:(NSNotification*)aNotification 
{
    MPMoviePlayerController* theMovie=[aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                    name:MPMoviePlayerPlaybackDidFinishNotification 
                                                  object:theMovie]; 

    // Release the movie instance created in playMovieAtURL
    [theMovie release]; 
}

不确定这是否是您的情况,但以下是关于MPMoviePlayerPlaybackDidFinishNotification的文档说明:

在某些情况下不发送此通知 电影播放器正在显示的位置 在全屏模式下,用户点击 “完成”按钮。在这种情况下 “完成”按钮使电影播放停止 暂停播放,让播放机退出 全屏模式。如果你想 如果在代码中检测到这种情况,则 应监视其他通知 例如 MPMoviePlayerDiexitFullScreenNotification

似乎仅当电影本身停止时,才会调用MPMoviePlayerPlaybackDidFinishNotification。
如果您使用的是“完成”按钮,则应改用MPMoviePlayerDexitFullScreenNotification。

我试图通过传递nil来解决此问题,但现在它会返回我的回调,但电影仍不会发布,我也会尝试您的建议。无论如何,我的新代码

-(void) playMovieAtURL
{

MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]];
mpViewController.view.backgroundColor = [UIColor blackColor];
[self presentMoviePlayerViewControllerAnimated:mpViewController];

[mpViewController.view setCenter:self.view.center];

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

} 

// When the movie is done,release the controller. 
-(void)myMovieFinishedCallback:(NSNotification*)aNotification 
{
    MPMoviePlayerController* theMovie=[aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
        name:MPMoviePlayerPlaybackDidFinishNotification 
        object:nil]; 

    // Release the movie instance created in playMovieAtURL
    [theMovie release]; 
}

你要释放你的电影播放器吗