完成按钮事件MPMoviePlayerController

完成按钮事件MPMoviePlayerController

本文介绍了完成按钮事件MPMoviePlayerController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone上,我正在以全屏模式播放视频/音频文件。当视频/音频文件到达终点时,将触发以下方法:

On my iPhone i'm playing video/audio files in fullscreen mode. When the video/audio file reached its end then the following method is triggered:

- (void) movieFinishedCallback:(NSNotification*) aNotification {
    MPMoviePlayerController *player = [aNotification object];

    [player stop];

    [[NSNotificationCenter defaultCenter]
        removeObserver:self
        name:MPMoviePlayerPlaybackDidFinishNotification
        object:player];

    [player autorelease];
    [moviePlayer.view removeFromSuperview];

    NSLog(@"stopped?");
}

工作正常!但问题是当视频/音频文件仍在播放时我按下完成按钮。然后这个方法不会被触发......

That works fine! But the problem is when i press on the "Done" button when the video/audio file is still playing. Then this method doesn't get triggered...

任何人都知道在按下完成按钮时如何捕获事件?因为现在媒体播放器仍然在视图中。它没有消失。

Anyone any idea how to catch the event when the "Done" button is pressed? Because right now media player stays in the view. Its not disappearing.

推荐答案

当我收听
MPMoviePlayerWillExitFullscreenNotification时,我在iPad上工作了

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(doneButtonClick:)
                                             name:MPMoviePlayerWillExitFullscreenNotification
                                           object:nil];

选择器方法:

-(void)doneButtonClick:(NSNotification*)aNotification{
    NSNumber *reason = [notification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];

    if ([reason intValue] == MPMovieFinishReasonUserExited) {
        // Your done button action here
    }
}

这篇关于完成按钮事件MPMoviePlayerController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 04:20