Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #486892

    Hi,

    I have embeded a YouTube video in the sidebar of my blog (podcast). I want it to auto play ONLY the first time they visit, then have it be click-to-play on subsequent visits. Currently, if they surf around, the video starts playing each time they access a blog post.

    I found some code that is supposed to work, but when I add a text widget and the corresponding php below, it doesn’t seem to recognize it. Instead, you see two instances of the video, one which auto play and another that is click to play. I have also added the other code to the header as instructed.

    For now, I’ve deleted the php in the text widget so it only appears once. Hoping we can get this resolved.

    Any suggestions?

    Thanks

    ==============================================

    Place this at the very top of header.php

    ==============================================

    <?php
    $value = “1”;
    // send a cookie that expires in 1 year
    setcookie(“video_viewed”,$value, time()+60*60*24*30*12);
    ?>

    ==============================================

    Place this at the appropriate position within your Template. Be sure you have the “autoplay” and “non-autoplay” versions of your video player ready.

    ==============================================

    <?php
    // If Cookie is set
    if ($_COOKIE[“video_viewed”] == “1”) {
    ?>
    INSERTNONAUTOPLAYVIDEOCODEHERE
    <?php
    } else { ?>
    INSERTAUTOPLAYVIDEOCODEHERE
    <?php }
    // End Conditional Region
    ?>

    #486921

    Hey!

    PHP code is not allowed in normal Text widgets, maybe this plugin could the trick:
    https://wordpress.org/plugins/php-code-widget/

    Don’t forget to add the code to header.php too.

    Best regards,
    Josue

    #490578

    Hello I have a few videos that I’ve upload to my theme and they aren’t auto-playing… Any ideas? http://leibertbrooks.com

    Thanks…

    #490605

    Hey!

    Everything is possible, but that would need a lot of work to be done.

    You can contact one of our Customization Contractors, who will help you out with the process.
    http://kriesi.at/contact/customization

    Let us know if we could do anything else, regarding our theme

    Cheers!
    Basilis

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Making a YouTube video auto-play only the first time a user visits’ is closed to new replies.