
實例
啟用自動播放,并重載視頻:
myVid=document.getElementById( video1 myVid.autoplay=true;myVid.load();
定義和用法
autoplay 屬性設置或返回音視頻是否在加載后即開始播放。
瀏覽器支持
所有主流瀏覽器都支持 autoplay 屬性。
注釋:Internet Explorer 8 或更早的瀏覽器不支持該屬性。
語法
設置 autoplay 屬性:
audio|video.autoplay=true|false
返回 autoplay 屬性:
audio|video.autoplay
屬性值
值描述true指示音視頻在加載完成后隨即播放。false默認。指示音視頻不應在加載后立即播放。技術細節
返回值布爾值。true|false默認值:falsehtml5 video使用autoplay屬性時,聲音混亂
頁面代碼
Index.html
html xmlns= http://www.w3.org/1999/xhtml head title test /title meta charset= utf-8 / script src= js/jquery-1.4.4.min.js type= text/javascript /script script src= js/thml5.js type= text/javascript /script script type= text/javascript window.onload=function(){$( #channel1 ).click(function(){setConfig( test1.mp4 $( #channel2 ).click(function(){setConfig( test2.mp4 $( #channel3 ).click(function(){setConfig( test3.mp4
div id= test1 >js代碼
html5.jsvar HTML5MediaService= { getDefaultConfig: function () { return $.extend({}, {width: 100% , height: 100% , controls: controls , autoplay: autoplay }); create:function(jo,cfg){ this.videoId = videojs_ + new Date().getTime().toString(); var videoJo = $( video + id= + this.videoId + + src= + cfg.url + controls= + cfg.controls + autoplay= + cfg.autoplay + width= + cfg.width + height= + cfg.height + preload=none + /video videoJo.appendTo(jo.empty()); }我的解決方案:
取掉autoplay,可以使用play()函數來達到自動播放功能;
以上就是html5中設置或返回音視頻是否在加載后即開始播放的屬性autoplay的詳細內容,其它編程語言
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答