无法使用flashvars自动启动真正的YouTube API

时间:2012-12-26 08:47:18

标签: youtube-api swfobject

我有以下Javascript代码,但视频没有自动启动,为什么?

var params = { allowScriptAccess: "always" };
    var atts = { id: "myvideoplayer"};
    var flashvars = {autostart: true};

    swfobject.embedSWF(

        "http://www.youtube.com/v/MHRj8BYm240?enablejsapi=1&playerapiid=ytplayer&version=3", "ytplayer", "425", "365", "8", null, flashvars, params, atts);

    function onYouTubePlayerReady(playerId) {
    ytplayer = document.getElementById("myvideoplayer");
    //ytplayer.playVideo();
}

好吧,也许我应该在YouTube播放器准备好后立即使用playVideo(),但是可以使用其他flashvars,例如displayclickclick

1 个答案:

答案 0 :(得分:0)

将& autoplay = 1添加到视频网址,它应该可以正常工作