<html>
<body>
<audio id="myAudio1" controls>
<source src="/demo/horse.ogg" type="audio/ogg">
<source src="/demo/horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</source></source></audio>
<audio id="myAudio2" controls>
<source src="/demo/horse.ogg" type="audio/ogg">
<source src="/demo/horse.mp3" type="audio/mpeg">
您的浏览器不支持 audio 元素。
</source></source></audio><br>
<button onclick="setMedGroup()" type="button">为两段音频设置媒体组合</button>
<button onclick="getMedGroup()" type="button">获取媒体组合</button>
<script>
var x = document.getElementById("myAudio1");
var y = document.getElementById("myAudio2");
function setMedGroup()
{
x.mediaGroup = "test";
y.mediaGroup = "test";
}
function getMedGroup()
{
alert("Audio 1 media group: " + x.mediaGroup +
". Audio 2 media group: " + y.mediaGroup);
}
</script>
</body>
</html>