Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-05-20
7
Medium Priority
?
1,562 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 33

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 26

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 26

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 26

Author Comment

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

Author Closing Comment

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

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

721 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