skip to Main Content

On my Prestashop I use YouTube videos in some product tabs. Here is an exemple :

<ul id="tabvideos" class="video_cols_6">
 <li id="thumb_video_118" class="video_link">
   <a id="video_link_1" class="videocenter" href="https://www.youtube-nocookie.com/embed/ehzbdk" title="Vidéo: e" data-video-id="zdsdsdsd" data-video-player="youtube" data-video-title=""><img class="img-responsive" src="https://i.ytimg.com/vi/TLHyVedfdsssdsdnOzs10/hqdefault.jpg" alt="e vidéo" title="e vidéo">
   </a>
 </li>
</ul>

We use a module and autoplay should be activated. It seems that a previous developer has been integrating some script somewhere to cancel this.

How to make all the YT videos on the website in autoplay?

2

Answers


  1. Chosen as BEST ANSWER

    Here are the two codes I found related to autoplay in different files. How to edit them to make it autoplay? Thanks.

    product-video-1.4.js

        function printvideo(selector,vurl,width,height)
    {
        // Si esta buit posa el video
        if ($("#videoholder").val() != "" || typeof($("#videoholder").val()) == "undefined") {
            if (vurl.provider == "youtube")
                $(selector).prepend('<div id="videoholder"><iframe width="'+width+'" height="'+height+'" src="//www.youtube.com/embed/'+vurl.id+'?autoplay=1" frameborder="0" allowfullscreen></iframe></div>').show();
            else
                $(selector).prepend('<div id="videoholder"><iframe src="//player.vimeo.com/video/'+vurl.id+'" width="'+width+'" height="'+height+'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>').show();
        }
    

    tabcontent-1.7.tpl

     <script type="text/javascript">
        function printBigVideo(selector, target, vurl, width, height)
        {
            var autoplay = '';
            if (pv_auto == 1) {
                autoplay = 1;
            } else {
                autoplay = 0;
            }
            // Si esta buit posa el video
            if ( typeof($(target).val()) == "undefined" || $(target).val() == "")
            {
                if (vurl.provider == "youtube")
                    $(selector).prepend('<div id="'+target.replace('#','')+'"><iframe style="z-index:'+pv_image_zindex+'" width="'+width+'" height="'+height+'" src="//www.youtube.com/embed/'+vurl.id+'?vq=hd720p60&amp;autoplay='+autoplay+'&rel='+pv_rel+'" frameborder="0" allowfullscreen></iframe></div>').show();
                else
                {
                    $(selector).prepend('<div id="videoproduct"><iframe style="z-index:'+pv_image_zindex+'" src="//player.vimeo.com/video/'+vurl.id+'?color={/literal}{$pv_evars.pv_vim_color|escape:'htmlall':'UTF-8'|substr:1}{literal}" width="'+width+'" height="'+height+'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>').show();
                }
            }
            $('html, body').animate({
                scrollTop: $(target).offset().top-80
             }, 500);
        }
    

  2. First find the script that is cancelling the autoplay. It could be in ur theme files, custom modules or directly embedded in the Pretashop backend.

    After finding the script look for a code that looks like this

    src="https://www.youtube-nocookie.com/embed/ehzbdk"
    

    Then replace it with this:

    src="https://www.youtube-nocookie.com/embed/ehzbdk?autoplay=1"
    

    But if you are unable to find the script I think it is better to contact the previous developer.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search