【发布时间】:2010-11-12 18:24:23
【问题描述】:
我在使用 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,然后调用不起作用的 play。
//Stop the player and restart it
if (player.playing) {
NSLog(@"Reset sound: %@", selectedSound);
player.currentTime = 0;
[player play];
} else {
NSLog(@"playSound: %@", selectedSound);
[player play];
}
【问题讨论】:
标签: iphone audio core-audio avaudioplayer