I have an audio file (mp3) which I have to play in different BMPs. I want some way to change the current BMP of the song and play at it.
我有一个音频文件(mp3),我必须在不同的BMP中播放。我想用一些方法改变歌曲的当前BMP并播放它。
There is a picker which lets user to pick BMP at which he wants the song to play:
有一个选择器,让用户可以选择他想要播放歌曲的BMP:
1 个解决方案
#1
1
You can change the speed of audio player. Say you alreay know that BPM is 60 and now you want to play it at 90, you simply need to make the play speed 1.5 times faster by using the following code
您可以更改音频播放器的速度。比如说你知道BPM是60,现在想要在90下播放,你需要通过使用下面的代码让播放速度提高1.5倍
let audioP = try! AVAudioPlayer(contentsOf: URL(fileURLWithPath: selectedPath), fileTypeHint: "caf")
audioP.enableRate = true
audioP.prepareToPlay()
audioP.rate = 1.5// Change your rate here
audioP.play()
#1
1
You can change the speed of audio player. Say you alreay know that BPM is 60 and now you want to play it at 90, you simply need to make the play speed 1.5 times faster by using the following code
您可以更改音频播放器的速度。比如说你知道BPM是60,现在想要在90下播放,你需要通过使用下面的代码让播放速度提高1.5倍
let audioP = try! AVAudioPlayer(contentsOf: URL(fileURLWithPath: selectedPath), fileTypeHint: "caf")
audioP.enableRate = true
audioP.prepareToPlay()
audioP.rate = 1.5// Change your rate here
audioP.play()