AVAudioPlayer を使用して、現在再生中のプレーヤーをリセットして再度再生したい場合に問題が発生しています。
私は運がないので次のことを試します:
サウンドは1回再生されますが、2回目にボタンを選択するとサウンドが停止し、3回目にサウンドが再び開始されます。
//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];
}