Solved

How to set one Youtube video to autoplay only once using cookie

Posted on 2013-05-20
7
1,211 Views
Last Modified: 2013-07-02
Hi,

I need to set cookies for youtube video that will autoplay only once per session.
(let say 12 hours or 24 hours)

- I have a youtube video in the footer of a site this is the one that need to autoplay only once per sessions.

- I have a youtube videos page with videos that are not autoplay, so the code should not interfere with those videos.

- The way the autoplay video is embeded is like this:
<iframe src="http://www.youtube.com/embed/XXXXXXXXXXX?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>

Most of the javascript code I have found embed the url
I don't need this the urls are already in place I just need to set cookies for one video.

PS I have to do this for one PHP website and for one HTML website

Thanks
0
Comment
Question by:lenamtl
  • 4
  • 2
7 Comments
 
LVL 32

Accepted Solution

by:
Big Monty earned 175 total points
ID: 39181628
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 175 total points
ID: 39181638
The design here is similar to the design of a "splash" page, that is shown once and then suppressed thereafter.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_3314-How-to-Show-an-Introductory-Web-Page-Once-Using-PHP.html

Suggest you take the HTML web site and make it a PHP web site.  You can make PHP parse HTML documents, and you will not have to change a think in the HTML documents.  But you will be able to add PHP scripts to them!  Here is my .htaccess from a site where I did that.
ErrorDocument 404 /404handler.php
AddType application/x-httpd-php5 .html .htm .php

Open in new window

Best regards, ~Ray
0
 
LVL 24

Author Comment

by:lenamtl
ID: 39181707
Hi,
The_Big_Daddy

I have seen this tutorial before but it's not exactly what I need
This example embeded a URL and I don't need this part.
If you know how to adapt it let me know
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 24

Author Comment

by:lenamtl
ID: 39181725
Hi Ray,

Thanks for the tutorial
In my case the video is in the footer, I want the video to be available for a second play but I do not want the video autoplay on each page (because located in the footer).

Your solution will work well on a splash page, I really don't know how to adapt it to a youtube video. (it maybe overkill for my needs)
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39181776
Working with your current experience about YouTube videos, can you bring up the same video, once in autoplay and once not in autoplay?  If the answer to that is "yes" then you're more than halfway there.  

You can use PHP to generate the browser code that differentiates autoplay from static preview.  Your script can set a cookie that says, "I have already autoplayed this video."  When your server-side script is started, it can check for the cookie.  If the cookie is not there, set the cookie and generate the autoplay code.  If the cookie is there, set the cookie and generate the static preview code.
0
 
LVL 24

Author Comment

by:lenamtl
ID: 39198053
I'm doing some tests and will get back to you soon
0
 
LVL 24

Author Closing Comment

by:lenamtl
ID: 39293541
I have not used these options but they are potential solutions.
Thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now