0
我有一個網站,並在主頁上我有一個嵌入的YouTube視頻,即包含玩家最初是隱藏在div(顯示:無),因此,一個按鈕(視頻)被點擊時,我隱藏頁面的內容並顯示YouTube播放器,所有工作都可以,但是當點擊按鈕(視頻)時,播放器出現並開始自動再現視頻,但我很喜歡它,但是我在每次嘗試中都出現了錯誤,我使用的是我在其他網站找到一個代碼,並做了一些改動自動播放YouTube視頻
swfobject.addLoadEvent(ytplayer_render_player);
function ytplayer_render_player()
{
swfobject.embedSWF
(
'http://www.youtube.com/v/' + youtube_uhma.home + '&enablejsapi=1&rel=0&fs=1&playerapiid=ytplayer',
'ytplayer_div1',
'425',
'344',
'8',
null,
null,
{
allowScriptAccess: 'always',
allowFullScreen: 'true'
},
{
id: 'ytplayer_object'
}
);
}
function onYouTubePlayerReady(playerid)
{
var o = document.getElementById('ytplayer_object');
if (o)
{
o.addEventListener("onStateChange", "ytplayer_statechange");
o.addEventListener("onError", "ytplayer_error");
}
}
function ytplayer_statechange(state)
{
if (state == 0)
{
ytplayer_playlazy(5000);
}
}
function ytplayer_error(error)
{
if (error)
{
ytplayer_playlazy(5000);
}
}
function ytplayer_playlazy(delay)
{
if (typeof ytplayer_playlazy.timeoutid != 'undefined')
{
window.clearTimeout(ytplayer_playlazy.timeoutid);
}
ytplayer_playlazy.timeoutid = window.setTimeout(ytplayer_play, delay);
}
function ytplayer_play()
{
var o = document.getElementById('ytplayer_object');
if (o)
{
o.loadVideoById(youtube_uhma.home);
}
}
我文章中,我使用了整個代碼,所以,我怎樣才能使自動播放在這裏,你可以看到我的網站在這裏採取行動Uhma
謝謝所有
Youtube如何繞過WebKit HTML5 video'muted'? – moeseth 2017-08-17 16:33:36