5
我有一個綁定到onClick事件的函數。它應該播放一首歌。如果有一首歌曲正在播放,應該停止播放當前歌曲並開始播放新歌曲。唯一的問題是,據我所知,只有一個暫停方法,這意味着上一首歌曲將從暫停位置,而不是開始。有沒有辦法解決這個問題(比如.stop()方法)?在Javascript中啓動和停止音頻
這裏是我的代碼:
var currSong="";
function playSong(newSong){
alert(newSong);
if (newSong != ""){
if(currSong != "") {
document.getElementById(currSong).pause();
}
document.getElementById(newSong).play();
currSong = newSong;
}
}
這是HTML5音頻API? – 2011-02-07 23:19:13
我猜,這是一個