[ACCEPTED]-AVAudioPlayer: How to Change the Playback Speed of Audio?-avaudioplayer
Accepted answer
Now it is possible to change the playback 2 speed.
Sample code:
player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&err];
player.volume = 0.4f;
player.enableRate = YES; //<--
[player prepareToPlay];
[player setNumberOfLoops:0];
player.rate = 2.0f; //<-- Playback Speed
[player play];
enableRate
is set to YES
and you can 1 change it.
See more in the docs.
Swift 2 - Swift 5
You can increase the rate by doing this:
player.enableRate = true
player.prepareToPlay()
player.rate = 2.0
player.play()
If you want to loop, you can add this:
player.numberOfLoops = 3
0
Try this -
audioP = try! AVAudioPlayer(contentsOf: URL(fileURLWithPath: selectedPath), fileTypeHint: "caf")
audioP.enableRate = true
audioP.prepareToPlay()
audioP.rate = 1.5
audioP.play()
0
You can't. You can only change the volume 4 not the speed of playback.
I think to do 3 that, you will have to use the much lower 2 level Audio Queue APIs and manipulate the audio stream 1 manually to apply that effect.
set enableRate = YES and then you can adjust 2 the rate between 0.1 and 2.0 for slowed 1 down and sped up (1.0 is normal speed)
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.