javascript - Pause youtube video when slide the next item -


i using bootstrap slider on page. need pause playing video when slider moves next one. tried using youtube callback doesnt seems working, may way of applying not right.

here have used

jquery(function ($) {         $('div.carousel-inner div.active').attr('id', 'current');     });      function callplayer(frame_id, func, args='') {          if (window.jquery && frame_id instanceof jquery) frame_id = frame_id.get(0).id;         var iframe = document.getelementbyid(frame_id);         if (iframe && iframe.tagname.touppercase() != 'iframe') {             iframe = iframe.getelementsbytagname('iframe')[0];         }         if (iframe) {             iframe.contentwindow.postmessage(json.stringify({                 "event": "command",                 "func": func,                 "args": args || [],                 "id": frame_id             }), "*");         }          jquery(function ($) {             $('div.carousel-inner div.item').attr('id', '');             $('div.carousel-inner div.active').attr('id', 'current');         });     } 

demo

demo

i modified html follows.

- onclick="callplayer("current","pausevideo")" + onclick="callplayer('current','pausevideo')" 

and change load type onload no wrap in <head>.

however, should attach click event jquery on method.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -