Skip to content

Instantly share code, notes, and snippets.

@evgeny-ilyin
Forked from cferdinandi/stop-video.js
Created June 6, 2024 13:57
Show Gist options
  • Save evgeny-ilyin/d2f8f3f2f0dd08b0d9cb2862e063cd16 to your computer and use it in GitHub Desktop.
Save evgeny-ilyin/d2f8f3f2f0dd08b0d9cb2862e063cd16 to your computer and use it in GitHub Desktop.

Revisions

  1. Chris Ferdinandi revised this gist Jun 6, 2014. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions stop-video.js
    Original 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 !== null ) {
    if ( iframe ) {
    var iframeSrc = iframe.src;
    iframe.src = iframeSrc;
    }
    if ( video !== null ) {
    if ( video ) {
    video.pause();
    }
    };
  2. Chris Ferdinandi created this gist Feb 17, 2014.
    11 changes: 11 additions & 0 deletions stop-video.js
    Original 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();
    }
    };