gotovideo.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. $(".video-img").click(function () {
  2. var videosrc = $(this).data("info");
  3. console.log(videosrc);
  4. $('.youtube-video').attr('src', `https://www.youtube.com/embed//${videosrc}?autoplay=1`);
  5. });
  6. $(".btn-close").click(function () {
  7. $('.youtube-video').attr('src', ``);
  8. });
  9. $('#exampleModal').on('hidden.bs.modal', function () {
  10. $('.youtube-video').attr('src', ``);
  11. });
  12. // $('.play-video').click(function(){
  13. // $('.youtube-video')[0].contentWindow.postMessage('{"event":"command","func":"' + 'playVideo' + '","args":""}', '*');
  14. // });
  15. // function autoPlayYouTubeModal() {
  16. // var trigger = $("body").find('[data-toggle="modal"]');
  17. // trigger.click(function () {
  18. // var theModal = $(this).data("target"),
  19. // videoSRC = $(this).attr("data-theVideo"),
  20. // videoSRCauto = videoSRC + "?autoplay=1";
  21. // $(theModal + ' iframe').attr('src', videoSRCauto);
  22. // $(theModal + ' button.close').click(function () {
  23. // $(theModal + ' iframe').attr('src', videoSRC);
  24. // });
  25. // });
  26. // }
  27. // $(document).on("click", ".btn-close", function (event) {
  28. // $('.youtube-video').each(function () {
  29. // this.contentWindow.postMessage('{"event": "command", "func": "stopVideo", "args": ""}', '*');
  30. // });
  31. // console.log('stop');
  32. // });
  33. // $(document).on("click", "#exampleModal", function (event) {
  34. // $('.youtube-video').each(function () {
  35. // this.contentWindow.postMessage('{"event": "command", "func": "stopVideo", "args": ""}', '*');
  36. // });
  37. // });