views:

700

answers:

1

A player: http://www.yvoschaap.com/videowall/

How can you customise the above Chromeless Youtube to have Play/Stop/Pause buttons?

Info on YouTube chromeless player provided by Google:

http://code.google.com/apis/youtube/chromeless_player_reference.html
http://code.google.com/apis/ajax/playground/?exp=youtube#chromeless_player

+1  A: 

It says right at the top...

/*
 * Chromeless player has no controls.
 */

The way to add those links on the page that will play/pause/mute/unmute is as follows.

Add these functions to your page (you already have them there but under different names - either paste these in, or correct your existing code to match the examples offered int he Code Playground)

function playVideo() {
  if (ytplayer) {
    ytplayer.playVideo();
  }
}

function pauseVideo() {
  if (ytplayer) {
    ytplayer.pauseVideo();
  }
}

function muteVideo() {
  if(ytplayer) {
    ytplayer.mute();
  }
}

function unMuteVideo() {
  if(ytplayer) {
    ytplayer.unMute();
  }
}

To add those links to your page, add the following code to your site:

<a href="javascript:void(0);" onclick="playVideo();">Play</a>
<a href="javascript:void(0);" onclick="pauseVideo();">Pause</a>
<a href="javascript:void(0);" onclick="muteVideo();">Mute</a>
<a href="javascript:void(0);" onclick="unMuteVideo();">Unmute</a>
Izzy
I just wondered why it is possible to recursively (i think) to do: "function playVideo() { if (ytplayer) { ytplayer.playVideo(); }}"-------You define playVideo() -function and call the function within itself. Then, the next playVideo does the same thing. Why would it work?
In short, I cannot understand the loop.
Izzy: Great Thanks! I got it finally working :)
I knew it would make sense if you kept at it!