Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Implement MPMoviePlayerController in just a few lines of code
let movieController: MPMoviePlayerViewController = MPMoviePlayerViewController(contentURL: NSURL(http://content.jwplatform.com/manifests/vM7nH0Kl.m3u8))
presentMoviePlayerViewControllerAnimated(movieController)
movieController.moviePlayer.play()

Hi Gavin, this AVPlayer tutorial is the most elegant and brief solution that I found in goole. I added a function call "avPlayer.seekToTime(CMTimeMakeWithSeconds(elapsedTime, 10))" in func sliderValueChanged(slider: UISlider!) to update the video screen when user dragged the slider. Here is the github link https://github.com/Charles-Hsu/CustomVideoPlayer.

Owner

intmainvoid commented Mar 6, 2016

Thanks for the compliment Charles (for those that didn't come here via the article - Charles is referring to this).

Just a word of caution on adding the method invocation you suggest: Attempting to seek inside sliderValueChanged saturates the AVPlayer in network dependent seek requests and as such can significantly degrade the user experience in the case where the video is being streamed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment