Youtube Javascript API – Basic Example

The following example illustrates the basic controls of the Youtube Javascript API to Play/Pause and Stop the videos:

<title>Youtube Javascript API - Basic Example</title>

<a href="#" onclick="controls('video_id','playVideo');  return false;">Play/Resume</a> <br /> 
<a href="#" onclick="controls('video_id','pauseVideo'); return false;">Pause</a> <br /> 
<a href="#" onclick="controls('video_id','stopVideo');  return false;">Stop</a> <br />

<iframe id="video_id" width="640" height="390" frameborder="0" type="text/html" src=";showinfo=0&controls=0&enablejsapi=1"></iframe>

	function controls(frame_id, func, args) {
	    var iframe = document.getElementById(frame_id);
	    if (iframe) {
	            "event": "command",
	            "func": func,
	            "args": args || [],
	            "id": frame_id
	        }), "*");