LoginSignup
5
9

More than 5 years have passed since last update.

【 Swift】AVPlayerで動画を指定時間まで進める方法

Last updated at Posted at 2016-10-12

AVFoundationのAVPlayerで動画を指定時間まで進めたいことがありましたので、
備忘の為投稿します!!よければご参考にしてください。

以下はNG

    videoPlayer.seekToTime(CMTimeMakeWithSeconds(Float64(seekBar.value), Int32(NSEC_PER_SEC)))

以下を使いましょう

    videoPlayer.seekToTime(CMTimeMakeWithSeconds(Float64(seekBar.value), Int32(NSEC_PER_SEC)), toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)

理由は、UISliderなどでシークで早送りする際に上の方法だと、滑らかに動画が早送りされない。(飛び飛びに早送りされてしまう)

5
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
9