gpt4 book ai didi

iphone - MPMoviePlayerPlaybackDidFinishNotification 在不应调用时被调用

转载 作者:行者123 更新时间:2023-12-03 18:48:49 28 4
gpt4 key购买 nike

根据 Apple 的 MPMoviePlayerController 文档:

MPMoviePlayerPlaybackDidFinishNotification -如果电影播放器​​以全屏模式显示并且用户点击“完成”按钮,则不会发送此通知。

在我看来这是完全错误的。使用下面的代码,当我点击完成按钮时,playerPlaybackDidFinish 就会被调用。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.player];

- (void) playerPlaybackDidFinish:(NSNotification*)notification
{
NSLog(@"WHY?");
self.player.fullscreen = NO;
}

我需要区分用户点击“完成”按钮和电影在播放过程中完成的情况。当电影结束时,playerPlaybackDidFinish 确实会被调用,但就像我说的,当您点击“完成”时,它也会被调用。

最佳答案

以下是如何检查 MPMoviePlayerPlaybackDidFinishReasonUserInfoKey,它是 MPMoviePlayerPlaybackDidFinishNotification 通知的一部分

- (void) playbackDidFinish:(NSNotification*)notification {
int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
if (reason == MPMovieFinishReasonPlaybackEnded) {
//movie finished playin
}else if (reason == MPMovieFinishReasonUserExited) {
//user hit the done button
}else if (reason == MPMovieFinishReasonPlaybackError) {
//error
}
}

关于iphone - MPMoviePlayerPlaybackDidFinishNotification 在不应调用时被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4158453/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com