简体   繁体   中英

Is it possible to change the audio play speed with AVAudioPlayer in iPhone?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM