首页 > 其他 > 详细

音频播放器兼容

时间:2018-03-05 14:59:44      阅读:235      评论:0      收藏:0      [点我收藏+]
  playSound(url);
    function playSound(url)
    {
        var borswer = window.navigator.userAgent.toLowerCase();

        if ( borswer.indexOf( "ie" ) >= 0 )
        {
            //IE内核浏览器

            var strEmbed = ‘<embed name="embedPlay" src="‘+url+‘" autostart="true" hidden="true" loop="false"></embed>‘;

            if ( $( "body" ).find( "embed" ).length < 1 ){
               
                $( "body" ).append( strEmbed );
            }

            var embed = document.embedPlay;

            //浏览器不支持 audion,则使用 embed 播放
            embed.volume = 100;
            //embed.play();这个不需要
        } else
        {
            //非IE内核浏览器
            var strAudio = "<audio id=‘audioPlay‘ src=‘"+url+"‘ hidden=‘true‘>";
            if ( $( "body" ).find( "audio" ).length < 1 ){
                $( "body" ).append( strAudio );
            }

            var audio = document.getElementById( "audioPlay" );

            //浏览器支持 audion
            audio.play();
        }
    }

 

音频播放器兼容

原文:https://www.cnblogs.com/kasher/p/8508799.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!