1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- $(".video-img").click(function () {
- var videosrc = $(this).data("info");
- console.log(videosrc);
- let VideoContent = `
- <style>
- .embed-container {
- position: relative;
- padding-bottom: 56.25%;
- height: 0;
- overflow: hidden;
- max-width: 100%;
- }
- .embed-container iframe,
- .embed-container object,
- .embed-container embed {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- }
- </style>
- <div class='embed-container'><iframe class='youtube-video' src='${videosrc}'
- frameborder='0' allowfullscreen></iframe></div>
- `;
- $('#video-modal').html(VideoContent);
- });
- $('.play-video').click(function(){
- $('.youtube-video')[0].contentWindow.postMessage('{"event":"command","func":"' + 'playVideo' + '","args":""}', '*');
- });
- // function autoPlayYouTubeModal() {
- // var trigger = $("body").find('[data-toggle="modal"]');
- // trigger.click(function () {
- // var theModal = $(this).data("target"),
- // videoSRC = $(this).attr("data-theVideo"),
- // videoSRCauto = videoSRC + "?autoplay=1";
- // $(theModal + ' iframe').attr('src', videoSRCauto);
- // $(theModal + ' button.close').click(function () {
- // $(theModal + ' iframe').attr('src', videoSRC);
- // });
- // });
- // }
- $(document).on("click", ".btn-close", function (event) {
- $('.youtube-video').each(function () {
- this.contentWindow.postMessage('{"event": "command", "func": "stopVideo", "args": ""}', '*');
- });
- console.log('stop');
- });
- $(document).on("click", "#exampleModal", function (event) {
- $('.youtube-video').each(function () {
- this.contentWindow.postMessage('{"event": "command", "func": "stopVideo", "args": ""}', '*');
- });
- // alert('111111')
- // window.location.reload();
- });
|