MPMoviePlayerController causing a MP _playbackInterruptionDidEndNotification on appDidBecomeActive

对着背影说爱祢 提交于 2020-01-07 02:17:06

问题


I have a navigation controller that pushes another view which plays video files. Everything is working fine and on the simulator there is no problem at all. The problem is when I test the application on the iPhone, the movies play well but if I press the home button on the iPhone then I launch the app again I receive the following warning in Xcode Debugging area:

2011-11-21 20:23:05.216 KMW[324:707] MP _playbackInterruptionDidEndNotification :: NSConcreteNotification 0x164e90 {name = AVController_PlaybackInterruptionDidEndNotification; object = ; userInfo = { "AVController_InterruptionStatusNotificationParameter" = "non-resumable.SoloAmbientSound"; "AVController_InterruptorNameNotificationParameter" = "AudioSession-324"; }}, _state = 0

Although this warning is appearing I can continue using the App and watch movies without any problem but I am afraid that in a certain situation this warning causes a problem. Here is how I am setting up the view that plays the movies:

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    NSString *path = [[NSBundle mainBundle] pathForResource:@"movieFileName" ofType:@"m4v"];
    movieURL = [NSURL fileURLWithPath:path];
    self.moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:movieURL] autorelease];

    [self.view addSubview:moviePlayer.view];
    moviePlayer.view.frame = CGRectMake(0, 10, 320, 181);
    [moviePlayer setControlStyle:MPMovieControlStyleNone];
    [moviePlayer play];
}

- (void) viewWillDisappear:(BOOL)animated
{
    [moviePlayer stop];
    [moviePlayer.view removeFromSuperview];
}

- (void)dealloc
{
    [movieURL release];
    [moviePlayer release];
    [super dealloc];
}

Any ideas about this strange warning?

来源:https://stackoverflow.com/questions/8218336/mpmovieplayercontroller-causing-a-mp-playbackinterruptiondidendnotification-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!