Solved

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

Posted on 2013-05-20
7
1,329 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 175 total points
ID: 39181628
0
 
LVL 110

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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 110

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
Ajax on ASP 2 42
How to show popup no matter what a user clicks on navigation wise 10 36
Slush on text 2 12
Make an array show the subkey and put it in a query 2 29
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

726 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