change <audio> src with javascript

后端 未结 6 1569
离开以前
离开以前 2020-11-27 04:52

I have multiple audio files that I want to stream based on the user selects. How do I do that? This is what I have so far and it doesn\'t seem to work.

*UPDATE: Mad

6条回答
  •  清酒与你
    2020-11-27 05:21

    with jQuery:

     $("#playerSource").attr("src", "new_src");
    
        var audio = $("#player");      
    
        audio[0].pause();
        audio[0].load();//suspends and restores all audio element
    
        if (isAutoplay) 
            audio[0].play();
    

提交回复
热议问题