示例代码 MoviePlayer 问题

发布于 2024-07-17 16:50:20 字数 230 浏览 6 评论 0原文

我之前已经发布过这个问题,但无法得到答案,所以我再次发布。是关于从 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝梦月影 2024-07-24 16:50:20

此问题仅出现在模拟器中,不会出现在实际设备上。
如果你想摆脱这个,你需要释放 MoviePlayer 并在每次播放电影时分配一个新的。 例如:

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

其他地方。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文