Solved

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

Posted on 2013-05-20
7
1,292 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 33

Accepted Solution

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

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 25

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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 25

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 109

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 25

Author Comment

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

Author Closing Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to make a good PHP + MySQL + JS pagination system? 3 31
PHP Mail error 3 26
HowTo set a global variable in javascript or jQuery 4 21
if (is_singular not working 5 17
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

792 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