5 Replies Latest reply on Apr 10, 2016 12:12 PM by ♥Schrene

    How to mute or pause an embedded youtube video with a click

    jowens85 Level 1

      I am trying to integrate youtube videos into some ads that I have been building, but when the user rolls the ad back up, the video keeps playing. Is there a way to either pause or mute the video on a click, and then un-mute or play the video if the user rolls it back down?

       

      I have gotten it to work by emptying the container, but then if the user rolls the ad back down, the video is gone.

       

      Here is how it's setup:

       

      Code on "Stage":

      var youtubevid = $("<iframe/>");

      sym.$("VideoHolder").empty().append(youtubevid);

      youtubevid.attr('type','text/html');

      youtubevid.attr('width','300');

      youtubevid.attr('height','169');

      youtubevid.attr('src','https://www.youtube.com/embed/RVwhS08g-qk?rel=0&showinfo=0');

      youtubevid.attr('frameborder','0');       // 1 | 0

      youtubevid.attr('allowfullscreen','0');   // 1 | 0

       

       

      Code on the button that rolls down the ad and autoplays the youtube video:

      sym.play("Contracted");

      sym.$("VideoHolder").show();

       

      When the "Contracted" timeline plays, it expands the ad and at the end of the expansion a trigger gets the youtube video playing.

       

      "Trigger" code:

      var youtubevid = $("<iframe/>");

      sym.$("VideoHolder").empty().append(youtubevid);

      youtubevid.attr('type','text/html');

      youtubevid.attr('width','300');

      youtubevid.attr('height','169');

      youtubevid.attr('src','https://www.youtube.com/embed/RVwhS08g-qk?autoplay=1;rel=0&showinfo=0');

      youtubevid.attr('frameborder','0');       // 1 | 0

      youtubevid.attr('allowfullscreen','0');   // 1 | 0

       

      Here is the ad: http://ads.pictela.com/view/130677/87b3d15f45ec47379fe7fd7e026580d1   Just roll over the banner at the bottom. Then when the "X" is clicked at the top right, the audio keeps going.