Jump to content

javascript to change youtube video


wolfkin

Recommended Posts

Redacted - http://pastebin.com/7VWdWmbP

 

Current HTML

http://pastebin.com/hGqDiyX5

 

It seems to me like my problem is I can't get swfobject.removeSWF("videodiv"); to work.

 

	<script type="text/javascript">
	$(function () {
		$('#switchtimer').countdown({
			until: '+6s',						// Time expires 60 seconds from load then calls change_video
			alwaysExpire: true,
			onExpiry: change_video 
			});

			function change_video() {
			var next_video = "Y4vLhJuKHxg";		// set next_video variable 
			var ytid = next_video				// change video from CD2LRROpph0 to Y4vLhJuKHxg
			swfobject.removeSWF("videodiv");
			swfobject.embedSWF("http://www.youtube.com/e/" + ytid + "?enablejsapi=1&playerapiid=ytplayer","videodiv", "640", "390", "8", null, null, params, atts);
			}
	});	
</script>


<script type="text/javascript">
	var params = { allowScriptAccess: "always" };
	var atts = { id: "myytplayer" };
	var ytid = "CD2LRROpph0";
	swfobject.embedSWF("http://www.youtube.com/e/" + ytid + "?enablejsapi=1&playerapiid=ytplayer","videodiv", "640", "390", "8", null, null, params, atts);
</script>

 

I'm trying to get the movie to switch from Movie A to Movie B when the timer finishes. I've gotten the JS to show Movie A and I've gotten the JS to show Movie B when the timer ends but I can't get it to switch from A to B. My best guess is swfobject.removeSWF isn't working and I'm not sure why.

Edited by wolfkin
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...