iOS MPMoviePlayerController 无法判断是否暂停或自动完成播放

标签 ios iphone

有一个问题,MPMoviePlayerPlaybackDidFinishNotification 将 playbackState 作为 MPMoviePlaybackStatePaused 发送给我,这两种情况是我暂停还是 moviePlayer 自动完成播放。

MPMoviePlaybackStateStopped 只有在我手动停止时才会发生,即 [moviePlayer stop]

知道如何区分自动完成或暂停的场景。

提前致谢

最佳答案

来自文档

The following key may be found in the userInfo dictionary of a MPMoviePlayerPlaybackDidFinishNotification notification.

Swift

let MPMoviePlayerPlaybackDidFinishReasonUserInfoKey: String

OBJECTIVE-C

NSString *const MPMoviePlayerPlaybackDidFinishReasonUserInfoKey;

然后

The value of this key is an NSNumber containing an integer value that represents one of the “MPMovieFinishReason” constants.

MPMovieFinishReason 是枚举,您有 PlaybackEndedUserExited

声明 快捷方式

enum MPMovieFinishReason : Int {
    case PlaybackEnded
    case PlaybackError
    case UserExited
}

objective-C

enum {
   MPMovieFinishReasonPlaybackEnded,
   MPMovieFinishReasonPlaybackError,
   MPMovieFinishReasonUserExited 
};
typedef NSInteger MPMovieFinishReason;

这是 documentation .

关于iOS MPMoviePlayerController 无法判断是否暂停或自动完成播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33751023/

相关文章:

ios - fopen$UNIX2003 在外部库内失败

ios - 通过自定义协议(protocol)符合协议(protocol) MKAnnotation

ios - 捆绑标识符不能从当前值更改

ios - 无法在 iOS 6.0 或 6.1 中运行应用程序

ios - FBSDKLikeControl 变灰/禁用

ios - XR 状态栏文本保持黑色,但 iPhone 8 或 iPad 不是

ios - 由于 Transporter,我的应用程序不会上传。我怎样才能绕过这个?

ios - 使用 RxSwift 定期调用 API

iphone - 平板电脑/移动设备上的数字内容被删除/隐藏

iphone - 在 iPhone 上启动游戏开发 :iPad - learning path?