使用 audio 和 embed 實現瀏覽器安全色的網頁聲音播放,audioembed

來源:互聯網
上載者:User

使用 audio 和 embed 實現瀏覽器安全色的網頁聲音播放,audioembed
使用 audio 和 embed 實現瀏覽器安全色的網頁聲音播放

使用 audio 和 embed 實現瀏覽器安全色的網頁聲音播放

學習參考源碼如下:

function playSound(){var borswer = window.navigator.userAgent.toLowerCase();if ( borswer.indexOf( "ie" ) >= 0 ){//IE核心瀏覽器var strEmbed = '<embed name="embedPlay" src="http://www.tnt168.com/public/wav/notice.wav" autostart="true" hidden="true" loop="false"></embed>';if ( $( "body" ).find( "embed" ).length <= 0 )$( "body" ).append( strEmbed );var embed = document.embedPlay;//瀏覽器不支援 audion,則使用 embed 播放embed.volume = 100;embed.play();} else{//非IE核心瀏覽器var strAudio = "<audio id='audioPlay' src='http://www.tnt168.com/public/wav/notice.wav' hidden='true'>";if ( $( "body" ).find( "audio" ).length <= 0 )$( "body" ).append( strAudio );var audio = document.getElementById( "audioPlay" );//瀏覽器支援 audionaudio.play();}}



html編寫網頁時,視頻與背景音樂不可以播放 用<embed src="url">編寫的,原來可以正常播放,解決辦法

不知道你要插入什麼內容,常見的flash檔案應該是有這樣的屬性
<embed width="860" align="middle" height="520" pluginspage="www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" src="musicbox_flash.swf">
如果你插入標籤屬性正常,哪麼可能是你測試的哪個瀏覽器沒安裝相應的外掛程式。
 
一個網頁中同時用embed插入音頻時的一個問題

我測試過都可以播放啊,會不會你IE的問題

另外也有可能你的網頁編碼要求比較嚴格
那請用完整模式:
<p/><embed src=1.mp3 autostart=false hidden=false />
<p/><embed src=2.mp3 autostart=false hidden=false />
<p/><embed src=3.mp3 autostart=false hidden=false />

這裡<p/>相當於<p></p>,其他元素同理
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.