示例代码MoviePlayer问题 [英] sample code MoviePlayer problem

查看:82
本文介绍了示例代码MoviePlayer问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前曾发布过此问题,但无法获得答案,因此我再次将其发布.是关于从iPhone开发者网站下载的MoviePlayer示例的信息,当我按电影播放器​​控制模式附带的完成"按钮时,电影就完成了,退出到主视图,同时调用了moviePlayBackDidFinish函数,但是当我再次播放电影时,播放器屏幕持续闪烁,如何防止这种情况发生?

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?

推荐答案

仅在模拟器中而不在实际设备上会出现此问题. 如果要消除这种情况,则每次播放电影时都需要释放MoviePlayer并分配一个新的MoviePlayer.例如:

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];
}

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

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

[thePlayer play];

在其他地方.

这篇关于示例代码MoviePlayer问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆