日期:2014-05-16  浏览次数:20293 次

web项目中有没有好用的播放声音的方法?
我的网站中有一个实时报警的功能.并且需要播放声音
我现在用的方法 .有这样既问题
1. 不支持谷歌浏览器,在谷歌浏览器中会不停的跳到页尾 也就是 我的声音控件位置
2. 火狐中 不能 播放声音
3. 运行久了 页面就崩溃.

以下是我的代码  ,请问有没有其他的好办法



<script type="text/javascript">
    $(function() {
        showmessage();
    });

    function showmessage() {
        $.ajax({
            dataType: "json",
            type: "POST",
            url: "/ajax/Message.ashx",
            cache: false,
            success: function(msg) {
                if (msg.id == 2) {
                    $('embed').remove();
                    $('body').append('<EMBED src="/img/NOTIFY.WAV" hidden="true" autostart="true" loop="false"> </EMBED>'); 
                }
                setTimeout("showmessage()", 30000);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                setTimeout("showmessage()", 30000);
            }
        });
       
    }

</script>


------解决方案--------------------
用flash 播放器
你看下http://www.hhxin.com/fmp/fmp.html
------解决方案--------------------
试试这个 jmp3在线播放mp3声音文件jquery插件
------解决方案--------------------
用html5
------解决方案--------------------
我前断时间也是用jq的插件。。支持HTML5.不支持的只能用flash播放。。楼主不要纠结了!