1

使用下面的代码来识别视频缓冲和播放时间。视频开始并暂停和缓冲。缓冲时需要显示加载器,开始播放时需要移除。尝试了两种方法,但没有正常工作。

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 是什么。在控制台中打印时也会出现这种情况。

请指导。

4

0 回答 0