scmmishra | 836a4b5 | 2018-10-08 15:26:05 +0530 | [diff] [blame^] | 1 | $(function () { |
| 2 | setTimeout(function () { |
| 3 | $(".later").fadeIn(); |
| 4 | }, 1000); |
| 5 | }); |
| 6 | |
| 7 | $(document).ready(function () { |
| 8 | |
| 9 | var $videoSrc; |
| 10 | // Gets the video src from the data-src on each button |
| 11 | $('.video-btn').click(function () { |
| 12 | $videoSrc = $(this).attr("data-src"); |
| 13 | console.log($videoSrc); |
| 14 | }); |
| 15 | console.log($videoSrc); |
| 16 | |
| 17 | |
| 18 | // when the modal is opened autoplay it |
| 19 | $('#myModal').on('shown.bs.modal', function (e) { |
| 20 | |
| 21 | // set the video src to autoplay and not to show related video. Youtube related video is like a box of chocolates... you never know what you're gonna get |
| 22 | $("#ytplayer").attr('src', "https://www.youtube.com/embed/" + $videoSrc + "?autoplay=0"); |
| 23 | }) |
| 24 | // stop playing the youtube video when I close the modal |
| 25 | $('#myModal').on('hide.bs.modal', function (e) { |
| 26 | // a poor man's stop video |
| 27 | $("#ytplayer").attr('src', $videoSrc); |
| 28 | }) |
| 29 | // document ready |
| 30 | }); |