Jump to content

Free help from tech experts
Welcome to Geeks to Go forums. Create a FREE account now to gain access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing topics, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. Best of all, registration and all assistance is 100% free! This message, and all ads will be removed once you have signed in.
Create an Account Login to Account

Video Autoplay


  • Please log in to reply

#1
jalternet

jalternet

    New Member

  • Member
  • Pip
  • 2 posts
Hi,

I have been looking for an answer for this problem for a longer time already....

my site is http://smarterealestate.com

I have one video set up to auto play once the page is visited or refreshed....

here is the code I have use:

<embed src="http://www.youtube.c...&hl&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="460" height="340"></embed>


.................


I hope somebody can show me a way to configure the video to only play once (for the first visit) --- so when the page is opened again, the video will not auto play anymore.
  • 0

Similar Topics: Video Autoplay     x


#2
TheBug

TheBug

    Member

  • Member
  • PipPip
  • 28 posts
You can use JavaScript to set a cookie that video has been played once. Read that cookie, it you get it, do not autoplay. Here is a sample. The cookie expires after number of days I have set days = 7. So after 7 days the video will autoplay again. Change var days = 7; if you want.

<script language="Javascript">
function played(){
	var ca = document.cookie.split(';');
	for(var i=0; i<ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf("played=") == 0) return 1;
	}
	var date = new Date();
	var days = 7;
	date.setTime(date.getTime()+(days*24*60*60*1000));
	document.cookie = "played=1"+"; expires="+date.toGMTString()+"; path=/";
	return 0;
}
if(played()==0){
	document.write("<embed src=\"http://www.youtube.com/v/z435EriT9eY&hl&autoplay=1\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"460\" height=\"340\"></embed>");
}
else{
	document.write("<embed src=\"http://www.youtube.com/v/z435EriT9eY&hl\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"460\" height=\"340\"></embed>");
}
</script>

Edited by TheBug, 19 February 2010 - 07:44 PM.

  • 0

#3
jalternet

jalternet

    New Member

  • Member
  • Pip
  • 2 posts
Hi TheBug!

Thank you very much for the reply and the suggestion... I tried putting the sample you made on my site and it WORKED!!!!

The sad news, Internet Explorer can't display the video... how can this be fixed????

it worked with Google Chrome and Firefox...

Thanks! The cookies thing made it play once only....
  • 0

#4
TheBug

TheBug

    Member

  • Member
  • PipPip
  • 28 posts
Maybe you do not have Adobe Flash ActiveX installed for IE. Adobe Flash plugins are different for IE and other browsers.

http://www.filehippo...flashplayer_ie/

Edited by TheBug, 19 February 2010 - 09:07 PM.

  • 0

#5
ilreoagent

ilreoagent

    New Member

  • Member
  • Pip
  • 1 posts
took a while to find this on google, thought it was a common thing, for me this works on all browsers except Chrome, I checked, and I don't have cookies blocked on chrome, so not sure why it plays on every visit in chrome.

Whoops nevermind, after a full play on Chrome it works!

For some reason on other browsers a full play isn't required, but a full play is required in Chrome...at least for me...Thanks TheBug

Edited by ilreoagent, 22 February 2011 - 02:59 PM.

  • 0

#6
drewdavid

drewdavid

    New Member

  • Member
  • Pip
  • 1 posts
Hi is there a way to use this with the new youtube embed codes? Thanks! I tried it and it was a no-go... (speaking if the iframe codes)

Thanks :)
  • 0


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

featured