JSFiddle - React, Tailwind, and code Playground
by salman
HTML
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js"></script>
<div id="ytapiplayer">
You need Flash player 8+ and JavaScript enabled to view this video.
</div>
<div>
<a href="#" onclick="load('hCarSDT7cSQ'); return false;">Video 1</a>
<a href="#" onclick="load('67aIIRv-dYU'); return false;">Video 2</a>
</div>
<div>
<a href="#" onclick="play(); return false;">Play</a>
<a href="#" onclick="pause(); return false;">Pause</a>
</div>
JavaScript
var ytplayer;
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myvideo");
}
var params = {
allowScriptAccess: "always"
};
var atts = {
id: "myvideo"
};
swfobject.embedSWF("http://www.youtube.com/v/hCarSDT7cSQ?enablejsapi=1&version=3", "ytapiplayer", "425", "270", "8", null, null, params, atts);
function play() {
if (ytplayer) {
ytplayer.playVideo();
}
}
function pause() {
if (ytplayer) {
ytplayer.pauseVideo();
}
}
function load(id) {
if (ytplayer) {
ytplayer.loadVideoById(id);
}
}