我使用AVAudioPlayer有,我想重置一个球员,如果它当前正在播放,并有再次发挥的问题。
我尝试没有运气如下:
声音播放一次,但然后我第二次选择它停止声音按钮,第三次再次启动的声音响了起来。
//Stop the player and restart it
if (player.playing) {
NSLog(@"Reset sound: %@", selectedSound);
[player stop];
[player play];
} else {
NSLog(@"playSound: %@", selectedSound);
[player play];
}
我已经使用player.currentTime = 0,这表明会重置播放器,没有工作,我也尝试重置currentTime的= 0,然后调用播放,没有工作也试过。
//Stop the player and restart it
if (player.playing) {
NSLog(@"Reset sound: %@", selectedSound);
player.currentTime = 0;
[player play];
} else {
NSLog(@"playSound: %@", selectedSound);
[player play];
}