0

I'm playing a local mp3 file with class 'AVAudioPlayer' on 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?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
squall
  • 1
  • 1
  • 1

2 Answers2

4

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

james shen
  • 491
  • 4
  • 5
0

That's not possible with AVAudioPlayer. See AVAudioPlayer: How to Change the Playback Speed of Audio? for potential workarounds.

Community
  • 1
  • 1
cellcortex
  • 3,166
  • 1
  • 24
  • 34