识别SWIFT中MPMoviePlayerController的缓冲状态

时间:2016-09-24 06:53:47

标签: ios iphone swift mpmoviewcontroller

使用以下代码识别视频缓冲和播放时间。视频启动并暂停和缓冲。需要在缓冲时显示加载程序并在开始播放时删除。尝试了两种方法,但没有正常工作。

if moviePlayer.loadState == MPMovieLoadState.Playable
    {
            print("playable")
        MBProgressHUD.hideAllHUDsForView(self.view, animated: true)
        print(moviePlayer.loadState)
    }
    if moviePlayer.loadState == MPMovieLoadState.PlaythroughOK
    {
        print("playable ok")
        MBProgressHUD.hideAllHUDsForView(self.view, animated: true)
        print(moviePlayer.loadState)
    }
    if moviePlayer.loadState == MPMovieLoadState.Stalled
    {
        print("stalled")
        print(moviePlayer.loadState)
    }
    if moviePlayer.loadState == MPMovieLoadState.Unknown
    {
        print("unknown")
        print(moviePlayer.loadState)

    }

尝试的第二种方法是:

if moviePlayer.playbackState == MPMoviePlaybackState.Stopped
    {
        print("stopped")
    }
    if moviePlayer.playbackState == MPMoviePlaybackState.Paused
    {
        print("paused")
         MBProgressHUD.hideAllHUDsForView(self.view, animated: true)

    }
    if moviePlayer.playbackState == MPMoviePlaybackState.Playing
    {
        print("playing")
         MBProgressHUD.hideAllHUDsForView(self.view, animated: true)

    }
    if moviePlayer.playbackState == MPMoviePlaybackState.Interrupted
    {
        print("interrupt")
    }
    if moviePlayer.playbackState == MPMoviePlaybackState.SeekingForward
    {
        print("SeekingForward")
    }
    if moviePlayer.playbackState == MPMoviePlaybackState.SeekingBackward
    {
        print("SeekingBackward")
    }

并且还想知道什么是loadState.rawValue 1,3和5.当在控制台中打印时也会出现这种情况。

请指导。

0 个答案:

没有答案