我不知道为什么它不起作用,我花了很多时间在它上面
我想更改音频播放器的源并在单击按钮时开始播放新源,代码如下:
JS:
<script type="text/javascript">
function audplay() {
var player = document.getElementById("Audio1");
audio = $("<audio>").attr("id", "audioElement")
.attr("preload", "auto")
.appendTo(player);
var sourceUrl = 'C:\Users\a\a\a\1.mp3'
function addMp3Source(sourceUrl) {
audio.empty();
var newSrc = $("<source>").attr("src",sourceUrl).appendTo(audio);
} }
</script>
HTML:
<audio id="Audio1" controls="controls" >
<source id='a' src="Miaow-07-Bubble.m4a" type="audio/mp4" />
<source src="demo.ogv" type="video/ogg" />
HTML5 Audio is required for this example.
<div id="buttonbar">
<button id="play" onclick="audplay()">></button>
</div>