页面有多个音频 播放当前暂停其他

<ul>
    <li>
        <audio id="aud0"  src="imgs/cd.mp3"  ></audio>
        <img class="bf-btn" id="playpause0" src="img/a16.png" alt=""/>
    </li>
    <li>
        <audio  id="aud1"  src="imgs/nl.mp3"  ></audio>
        <img class="bf-btn" id="playpause1" src="img/a16.png" alt=""/>
    </li>
    <li>
        <audio  id="aud2"  src="imgs/yy.mp3" ></audio>
        <img class="bf-btn" id="playpause2" src="img/a16.png" alt=""/>
    </li>
    <li>
        <audio  id="aud3"  src="imgs/cd.mp3"  ></audio>
        <img class="bf-btn" id="playpause3" src="img/a16.png" alt=""/>
    </li>
</ul>
 function play(num) {
        var audio = eval('aud' + num);
        audio.play();
        $("#playpause" + num).attr("src", url_prefix + "/img/a15.png");

    }
    function pause(num) {
        var audio = eval('aud' + num);
        audio.pause();
        audio.currentTime = 0;
        $("#playpause" + num).attr("src", url_prefix + "/img/a16.png");

    }
    $("#playpause0").click(function () {
        audioSW(0);
    });
    $("#playpause1").click(function () {
        audioSW(1);
    });
    $("#playpause2").click(function () {
        audioSW(2);
    });
    $("#playpause3").click(function () {
        audioSW(3);
    });
    $("#playpause4").click(function () {
        audioSW(4);
    });

欢迎分享本文,转载请保留出处:前端ABC » 页面有多个音频 播放当前暂停其他

赞 (1)
分享到:更多 ()

发表评论 0