Reputation: 1758
For example, play a local audio file with double speed or half speed.
I've already checked several Github projects, but none of them supports that.
Any idea about how to make it will be appreciated.
Upvotes: 1
Views: 1025
Reputation:
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.
Upvotes: 0
Reputation: 336
player.rate = 2.0 // Whatever speed you want
Assuming you're using AVAudioPlayer. you can change speed by changing the rate.
detail doc: https://developer.apple.com/documentation/avfoundation/avaudioplayer#jumpTo_15
Upvotes: 1