jquery - How to change the src attr in <audio> tag with another online mp3 resource and reload it -
i tried modify src attribute of tag , reload it. however, seems not work.
$.getjson('/handler', function(data) { var items=[] alert('data') $('#artist').html(data.artist); $('#title').html(data.title); $(".audio").attr('src', data.url); $(".audio").attr('autoplay', true); $(".audio").load(); } <audio id="players" class="audio" controls> <!-- <source src="horse.ogg" type="audio/ogg"> --> <source src="http://mr4.douban.com/201307252205/c015e7928c2cbcb3be6ad0e38ff21838/view/song/small/p1451474.mp3" type="audio/mp3" reload="auto" > browser not support audio element. </audio>
i did experiments, if change src local files like:
$(".audio").attr('src','/static/music/p186609.mp3')
this works, if use
$(".audio").attr('src','http://mr4.douban.com/201307252205/c015e7928c2cbcb3be6ad0e38ff21838/view/song/small/p1451474.mp3')
this not work.
this due browser policy prevent cross-site scripting.
Comments
Post a Comment