js 播放声音 MP3等

来源:互联网 发布:Java 请求499 编辑:程序博客网 时间:2024/04/28 19:20

js事件 ,播放声音:

html:

<html>
<body>
    <div id="voice">
    </div>
</body>
</html>


js:

比如在某个点击事件里写:

playVoice(/voices/test.mp3);


function playVoice(file) {
        $('#voice').html('<audio controls="controls" id="audio_player" style="display:none;"> <source src="' + file + '" > </audio><embed id="MPlayer_Alert" src="' + file + '" loop="false" width="0px" height="0px" /></embed>');
    }


0 0
原创粉丝点击