Installa la nostra toolbar!
Tips / Youtube
addthis
Enable fullscreen mode on Youtube player embedded via Javascript API
Author: Tafaz
Visits: 2307
Date: 17.10.2008

Youtube's APIS allow you to embed videos on websites simply using a Javascript code as explained here.

Youtube's Javascript Code:
  <script type="text/javascript" src="swfobject.js"></script>   
  <div id="ytapiplayer">
    You need Flash player 8+ and JavaScript enabled to view this video.
  </div>

  <script type="text/javascript">

    var params = { allowScriptAccess: "always" };
    var atts = { id: "myytplayer" };
    swfobject.embedSWF("http://www.youtube.com/v/VIDEO_ID",
                       "ytapiplayer", "425", "356", "8", null, null, params, atts);

  </script>

It's not specified how to add the button to enable fullscreen mode.
To allow this functionality you have to add allowFullScreen : "true" in the swfObject params and &fs=1 to the url of the Youtube's Player as explained in the code below:

  <script type="text/javascript" src="swfobject.js"></script>   
  <div id="ytapiplayer">
    You need Flash player 8+ and JavaScript enabled to view this video.
  </div>

  <script type="text/javascript">

    var params = { allowScriptAccess: "always", allowFullScreen: "true" };
    var atts = { id: "myytplayer" };
    swfobject.embedSWF("http://www.youtube.com/v/VIDEO_ID&fs=1",
                       "ytapiplayer", "425", "356", "8", null, null, params, atts);

  </script>




Page 1 of 1


Se vuoi discutere con noi su questo articolo o comunque vuoi porci delle domande usa il nostro Forum

COMMENTI

Aggiungi un commento! +
(I commenti verranno moderati prima della pubblicazione)

On 28.08.2009 Lunatic wrote:
Really helpfull comment. Thanks a lot :)


Top