$(".video-img").click(function () {
    var videosrc = $(this).data("info");
    $('.youtube-video').attr('src', `https://www.youtube.com/embed//${videosrc}?autoplay=1`);
});

$(".btn-close").click(function () {
    $('.youtube-video').attr('src', ``);
});

$('#exampleModal').on('hidden.bs.modal', function () {
    $('.youtube-video').attr('src', ``);
  });
// $('.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": ""}', '*');
//     });
    

// });