Skip to content

Instantly share code, notes, and snippets.

@MistyBlunch
Forked from cferdinandi/stop-video.js
Created July 4, 2018 15:44
Show Gist options
  • Select an option

  • Save MistyBlunch/9acf44715a4e704e6d5ecd40e25ec4fb to your computer and use it in GitHub Desktop.

Select an option

Save MistyBlunch/9acf44715a4e704e6d5ecd40e25ec4fb 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();
    }
    };