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(

This comment has been minimized.

Charles-Hsu commented Jan 1, 2016

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


This comment has been minimized.


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