Reputation: 87
I am working on AVPlayer
. I am done with Pause
, Play
and fastForward
of the playing audio stream. I want to change the playing speed of audio stream while playing. I have searched a lot, but not getting accurate direction. So, help me with this.
Upvotes: 4
Views: 12473
Reputation: 2186
You can use "rate"
private var player: AVPlayer?
....
player?.rate = 1.25
Upvotes: 3
Reputation: 479
The speed of playback depends upon the value for the rate
value; greater than 1.0 is faster, and for slow playback, use less than 1.0.
Upvotes: -3
Reputation: 331
You can increase or decrease the rate by this single line code:
// change the rate
Avplayer.playImmediately(atRate: 1.25)
Upvotes: 6
Reputation: 19966
The current rate of playback.
var rate: Float
Docs
A value of 0.0 means pauses the video, while a value of 1.0 play at the natural rate of the current item. Rates other than 0.0 and 1.0 can be used if the associated player item returns YES for the AVPlayerItem properties canPlaySlowForward or canPlayFastForward. Negative rate value ranges are supported if the player item returns YES for the canPlayReverse, canPlaySlowReverse, and canPlayFastReverse properties.
Upvotes: 23