-
-
Save johnny77221/dd49fba94330e80a8fa1ad60dd0ce7a4 to your computer and use it in GitHub Desktop.
Revisions
-
johnny77221 revised this gist
Sep 25, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ * @param {Element} element The element that contains the video */ var stopVideo = function ( element ) { element.querySelectorAll('iframe').forEach(function(iframe) { if ( iframe.contentWindow ) { /* send stop to content */ stopVideo(iframe.contentWindow.document); } -
johnny77221 revised this gist
Feb 14, 2019 . 1 changed file with 17 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,14 +2,20 @@ * Stop an iframe or HTML5 <video> from playing * @param {Element} element The element that contains the video */ var stopVideo = function ( element ) { element.querySelectorAll('iframe').forEach(function(item) { if ( iframe.contentWindow ) { /* send stop to content */ stopVideo(iframe.contentWindow.document); } else { /* Cross Domain, resetting src is all we can do, and the iframe might fail loading same url */ var iframeSrc = iframe.src; iframe.src = iframeSrc; } }); element.querySelectorAll('video').forEach(function(item) { item.pause(); }); element.querySelectorAll('audio').forEach(function(item) { item.pause(); }); }; // then call from top level document stopVideo(document); -
Chris Ferdinandi revised this gist
Jun 6, 2014 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,15 @@ /** * Stop an iframe or HTML5 <video> from playing * @param {Element} element The element that contains the video */ var stopVideo = function ( element ) { var iframe = element.querySelector( 'iframe'); var video = element.querySelector( 'video' ); if ( iframe ) { var iframeSrc = iframe.src; iframe.src = iframeSrc; } if ( video ) { video.pause(); } }; -
Chris Ferdinandi created this gist
Feb 17, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ var stopVideo = function ( element ) { var iframe = element.querySelector( 'iframe'); var video = element.querySelector( 'video' ); if ( iframe !== null ) { var iframeSrc = iframe.src; iframe.src = iframeSrc; } if ( video !== null ) { video.pause(); } };