Continue playing movie in MPMoviePlayerViewController in background

前端 未结 1 902
时光取名叫无心
时光取名叫无心 2020-12-22 07:50

I have an MPMoviePlayerViewController that plays a movie in my app.

Multitasking is enabled so that I can return to the home screen or lock the device and then use t

相关标签:
1条回答
  • 2020-12-22 08:19

    This works for me. Load a false url when video player done button pressed. For Example

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

    and implement

    - (void)moviePlaybackComplete:(NSNotification *)notification
    {
        self.playerViewController=[self.playerViewController initWithContentURL:[NSURL URLWithString:@"dummyUrl"]];
        [self.playerViewController.moviePlayer stop];
        MPMoviePlayerViewController *moviePlayerController = [notification object];
        [[NSNotificationCenter defaultCenter] removeObserver:self
                                                        name:MPMoviePlayerPlaybackDidFinishNotification
                                                      object:moviePlayerController];
    }
    

    This works just fine. Thanks

    0 讨论(0)
提交回复
热议问题