HTML5 audiopayer Whow暂停所有元素音频?

时间:2012-09-15 12:51:43

标签: html5 audio html5-audio

请在使用“media_audio_player”类停止所有元素音频时告诉我      example:

<audio src="./ConcertMedia/'.$i2['file'].'" class="media_audio_player"> </audio>
<audio src="./ConcertMedia/'.$i2['file'].'" class="media_audio_player"> </audio>
<audio src="./ConcertMedia/'.$i2['file'].'" class="media_audio_player"> </audio>
i want use code $('.media_audio_player').get(0).pause(); but he doesnt work...
Why not work code and what me need doing?

1 个答案:

答案 0 :(得分:0)

请根据应用于音频标签的类检查播放声音的代码。

    <html>
    <head>

    <script src="http://code.jquery.com/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    function playerClicked() {
        audio=$(".audioplayer").get(1);

            debugger;
            audio.load()
            if(audio.paused){
                audio.play();
            } else {
                audio.pause();
            }

    }
    </script>

    </head>
    <body>

    <a id ="storyplayer" href="javascript:playerClicked();">
    Click here to play.
    </a>
    <audio class ="audioplayer">
        <source src="sound/siol.mp3" type="audio/mpeg" >
    </audio>
    <audio class ="audioplayer">
        <source src="sound/siol.mp3" type="audio/mpeg" >
    </audio>
    </body>
    </html>