1var VideoHelper = { 2 addPlayOverlay: function (videoEl, videoCont, onPlay, onPause) { 3 var sets = VideoHelper.settings; 4 videoCont.classList.add(sets.containerClass); 5 6 videoEl.addEventListener('pause', function () { 7 videoCont.classList.add(sets.containerClass); 8 onPause && onPause(this); 9 }); 10 11 videoEl.addEventListener('play', function () { 12 videoCont.classList.remove(sets.containerClass); 13 onPlay && onPlay(this); 14 }); 15 16 videoEl.addEventListener('click', function (event) { 17 event.preventDefault(); 18 19 var videoCtx = this; 20 21 if(videoCtx.paused) { 22 videoCtx.play(); 23 } else { 24 var videoPromise = videoCtx.play(); 25 26 if (typeof(videoPromise) !== 'undefined') { 27 videoPromise.then(function() { 28 videoCtx.pause(); 29 }); 30 } 31 } 32 }); 33 }, 34 tryAutoplay: function (video, videoBlock) { 35 var promise = video.play(); 36 var context = this; 37 if (typeof (promise) !== 'undefined') { 38 promise['catch'](function (err) { 39 context.addPlayOverlay(video, videoBlock); 40 }); 41 } 42 }, 43 isVideoReadyToPlay: function(video) { 44 return (video.readyState >= 2 || video.preload !== "none"); 45 }, 46 play: function (video) { 47 var toggleVideoPlay = function (video) { 48 if (video.paused) { 49 video.play(); 50 } else { 51 video.pause(); 52 } 53 }; 54 var context = this; 55 if (context.isVideoReadyToPlay(video)) { 56 toggleVideoPlay(video); 57 } else { 58 video.addEventListener('loadeddata', function () { 59 if (context.isVideoReadyToPlay(video)) { 60 video.play(); 61 } 62 }); 63 } 64 }, 65 settings: { 66 containerClass: 'play-overlay' 67 } 68};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.