Can't get buffering status of live video with mpmovieplayercontroller ios

I am working on playing streaming video using MPmovieplayercontroller. I can also display the video playback time. I can play the video, but when it gets the buffer and restores its game state, in the meantime, it is not able to get the buffering state and so the timer does not update properly but jumps with some time. Is there a way to get it right? Please help me solve. thanks in advance

My code: -

   NSNotificationCenter.defaultCenter().addObserver(self, selector: "moviePlayBackStateChanged:", name: "MPMoviePlayerLoadStateDidChangeNotification",object:  moviePlayer)
    if(moviePlayer?.playableDuration > 0)
                        {
                            currentTime = moviePlayer!.currentPlaybackTime
                        }
                        else
                        {
                            currentTime = 0
                        }
    func moviePlayBackStateChanged(notification:NSNotification)
        {
            if(moviePlayer?.loadState == MPMovieLoadState.Playable)
            {
                currentTime = moviePlayer!.currentPlaybackTime
                println("currentTime\(currentTime)")
                lblTime?.text = stringFromTimeInterval(currentTime!)          
            }else if(moviePlayer?.loadState == MPMovieLoadState.Stalled)
            {
                lblTime?.text = stringFromTimeInterval(currentTime!)
            }
}

      

+3


source to share





All Articles