开发者

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

开发者 https://www.devze.com 2023-04-06 10:33 出处:网络
I\'mplaying 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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消