I'm playing a local mp3 file with class 'AVAudioPlayer' 开发者_如何学Goon my iOS App. And I want to change the speed when play it. such as I want to play this mp3 file slower.
How to achieve it?
Now it is possible to change the speed of sound.
here is my 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;
[player play];
you set "enableRate" to YES and you can change it.
see more docs
That's not possible with AVAudioPlayer. See AVAudioPlayer: How to Change the Playback Speed of Audio? for potential workarounds.
精彩评论