sample code MoviePlayer problem

爷,独闯天下 提交于 2019-12-07 18:41:27

问题


i have post this question before but cannot get a answer so i post it again.is about the MoviePlayer sample download from iphone developer site, when i press the Done button come with the movie player control mode, the movie was finish and exit to main view,at the same time the moviePlayBackDidFinish function have been called, however when i play the movie again, the player screen keep blinking,how to prevent this?

the code i didnt make any change is completly build from the sample code downloaded from apple site, have anybody met this problem before,and solve it?


回答1:


This problem is occurs only in the simulator not on the actual device. If you want to get rid of this you need to release the MoviePlayer and allocate a new one each time you play a movie. E.g.:

- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
    // remove observer
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:thePlayer];

    [thePlayer release];
}

and

thePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theMovie];

[[NSNotificationCenter defaultCenter] 
     addObserver:self 
     selector:@selector(moviePlayBackDidFinish:) 
     name:MPMoviePlayerPlaybackDidFinishNotification 
     object:thePlayer];

[thePlayer play];

elsewhere.



来源:https://stackoverflow.com/questions/771980/sample-code-movieplayer-problem

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