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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.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 检测MPMoviePlayerController何时暂停或停止_Iphone_Ios_Mpmovieplayercontroller - Fatal编程技术网

Iphone 检测MPMoviePlayerController何时暂停或停止

Iphone 检测MPMoviePlayerController何时暂停或停止,iphone,ios,mpmovieplayercontroller,Iphone,Ios,Mpmovieplayercontroller,我有两种症状: 1) 当我在下面的movieFinished:method中调用[ourmovierelease]时,我被告知我正在发布一些已经发布的内容。。[sentNotification object]传递给–movieFinished:的不是副本,因此我必须发布一些东西吗 2) 与(1)完全无关的是,当为MPMoviePlayerPlaybackDidFinishNotification添加NSNotification观察员时,电影不会显示。没有可检测的错误,只是没有显示??我的目标是检

我有两种症状:

1) 当我在下面的
movieFinished:
method中调用
[ourmovierelease]
时,我被告知我正在发布一些已经发布的内容。。
[sentNotification object]
传递给–
movieFinished:
的不是副本,因此我必须发布一些东西吗

2) 与(1)完全无关的是,当为
MPMoviePlayerPlaybackDidFinishNotification
添加NSNotification观察员时,电影不会显示。没有可检测的错误,只是没有显示??我的目标是检测用户何时暂停或停止播放,然后按下Home按钮将我的应用程序发送到后台。当应用程序返回前台时,我想继续播放用户按下暂停或停止按钮时留下的电影。。不像我的应用程序现在那样从头开始

在继续之前,我的AppDelegate中确实有以下内容:

[notificationCenter addObserver:self
                       selector:@selector(pauseApp)
                           name:@"UIApplicationDidEnterBackgroundNotification"
                         object:ourApp];
仅供参考:my–pauseApp最终会调用
[ourMovie pause]

在my–playVideo中:我拥有的方法

[notificationCenter addObserver:self
                       selector:@selector(movieFinished:)
                           name:MPMoviePlayerPlaybackDidFinishNotification
                         object:ourMovie];

[notificationCenter addObserver:self
                       selector:@selector(pauseDownload)
                           name:@"MPMoviePlayerPlaybackStateDidChangeNotification"
                         object:ourMovie];
- (void )movieFinished:(NSNotification *)sentNotification
{
    NSObject *theNotifyObject = [sentNotification object];

    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];

    if ( [theNotifyObject isKindOfClass:[MPMoviePlayerController class]] )
    {
        MPMoviePlayerController *ourMovie = (MPMoviePlayerController *)theNotifyObject;

        [notificationCenter removeObserver:self
                                      name:MPMoviePlayerPlaybackDidFinishNotification
                                    object:ourMovie];

        [notificationCenter removeObserver:self
                                      name:MPMoviePlayerPlaybackDidFinishNotification
                                    object:ourMovie];

        [ourMovie pause];
        [ourMovie stop];
        [ourMovie release];   // release what we don't own   ???
    }
}
对于我的电影制作方法,我有

[notificationCenter addObserver:self
                       selector:@selector(movieFinished:)
                           name:MPMoviePlayerPlaybackDidFinishNotification
                         object:ourMovie];

[notificationCenter addObserver:self
                       selector:@selector(pauseDownload)
                           name:@"MPMoviePlayerPlaybackStateDidChangeNotification"
                         object:ourMovie];
- (void )movieFinished:(NSNotification *)sentNotification
{
    NSObject *theNotifyObject = [sentNotification object];

    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];

    if ( [theNotifyObject isKindOfClass:[MPMoviePlayerController class]] )
    {
        MPMoviePlayerController *ourMovie = (MPMoviePlayerController *)theNotifyObject;

        [notificationCenter removeObserver:self
                                      name:MPMoviePlayerPlaybackDidFinishNotification
                                    object:ourMovie];

        [notificationCenter removeObserver:self
                                      name:MPMoviePlayerPlaybackDidFinishNotification
                                    object:ourMovie];

        [ourMovie pause];
        [ourMovie stop];
        [ourMovie release];   // release what we don't own   ???
    }
}
1) 不,您不必发布
ourMovie
。您没有复制任何内容,只是将对象作为参数传递给方法,从而引用内存中的同一位置。因此,如果您以前的内存管理在创建对象时是正确的,那么此时您无需执行任何操作

2) 如果您希望在同一时间从同一地点播放视频,那么在您调用
我们的电影
上的
暂停
后,您为什么还要调用
停止

这引用了苹果公司文档中的
stop
方法:“此方法停止播放当前项目,并将播放头重置为项目的开头。”