LoginSignup
10
12

More than 5 years have passed since last update.

AVPlayer#seekToTime で正確な時間に移動する

Posted at

iOS の動画編集アプリを作っている際に、動画の再生開始の位置を小刻みに調整し、かつ AVPlayer でのプレビューにその位置の映像を表示させたい場合があります。動画素材のトリミングの際などに。

単純に、特定の CMTime に対して、 AVPlayer#seekToTime: しただけでは、正確な位置に移動できません。つまりは、シークバー的な細かな移動の実装ができないことを意味します。

そのような実装をする場合は、以下のメソッドを利用するとよいみたいです。

AVPlayer#seekToTime:toleranceBefore:toleranceAfter:

[time-toleranceBefore, time+toleranceAfter] というように、範囲を含んだ形でメッセージを送ることで、正確な位置への移動が可能になります。

10
12
2

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
10
12