Youtube Javascript API - disable related videos

后端 未结 8 1097
小蘑菇
小蘑菇 2020-12-02 09:16

Right, this seems to be poorly documented or I can\'t see it in the documentation. I basically want no related videos (?rel=0) using the JavaScript API.

8条回答
  •  难免孤独
    2020-12-02 09:35

    If you're using SWFObject, you simply need to do something like this:

    function loadVideo() {
            var params = { allowScriptAccess: "always" }
                , atts = { id: "myvideo" }
            ;
    //NOTE THE END OF THE BELOW LINE vvvvvv
            swfobject.embedSWF("https://www.youtube.com/v/[video id here]?enablejsapi=1&playerapiid=myvideo&version=3&rel=0"
             , "videoplaceholderid"
             , "768", "432", "8", null, null, params, atts);
        }
    

    Just add rel=0 to the end of your url.

提交回复
热议问题