2012-03-01 94 views
1

全部, 我有一個網絡應用程序,在html5/javascript/css中傳輸音頻 當我啓動它並選擇一個流時,該流按預期播放。 當我試圖從該流切換到另一個網址時,程序會到達新網址緩衝區的位置,但沒有播放。我什麼都沒聽到。任何想法可能會發生在這裏? 在實際的智能手機設備上會發生此行爲。我在Chrome中運行該程序時不會發生這種情況。 這裏是我的代碼:無法切換HTML5音頻SRC

//global audio variable here 
var audio = new Audio; 
audio.setAttribute("autoplay","autoplay"); 
//Then within an function in the same jscipt file, I set the url. It's     
//when this runs a second time with a different url that it stalls. 
audio.pause(); 
audio.setAttribute("src", ""); 
audio.setAttribute("src", result.rows.item(q).url_); 
audio.load(); 

回答

0

audio.load();後,你需要調用audio.play();