Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-05-20
7
Medium Priority
?
1,631 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 34

Accepted Solution

by:
Big Monty earned 700 total points
ID: 39181628
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 700 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 27

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 27

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 111

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 27

Author Comment

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

Author Closing Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

916 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