Get video src

Get video src

by Lazaro Contreras

HTML

<button type="button">Get current video URL</button><br>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Ir7J0eEuWgk." frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

JavaScript

/* var vid = document.getElementById("myVideo");

function myFunction() {
  alert(vid.currentSrc);

  // GC From video tag & multiple video on page
  var videoTags = document.getElementsByTagName('video')
  for (var i = 0; i < videoTags.length; i++) {
    alert(videoTags.item(i).currentSrc);
  }

}  */
var vids = document.getElementsByTagName('video') 
// vids is an HTMLCollection
for( var i = 0; i < vids.length; i++ ){ 
    console.log( vids.item(i).src )
}


//$(document).ready(function() {
//$("button").click(function() {
$("button").on("click", function() {

  var HTML = document.documentElement.innerHTML;
  //alert(HTML);


  $("iframe,video source,video").each(function() {


    if (this.src.length > 0) {
      getVideo(this.src);
    }

    

    /*        var videoSRC = this.src;
                 console.log(videoSRC);
                 //alert(videoSRC);  
           
           if(typeof videoSRC !== "undefined" || videoSRC !== null) {
           
                 getVideo(videoSRC);
           
           }   */


    //getExt(videoSRC);

    /*     if (getType(videoSRC)) {
          console.log(videoSRC);
          alert(videoSRC);
        } */

  });

});

/* $("video").on("play", function() {
    var id = $(this).attr('id');

    $("video").not(this).each(function(index, video) {
        video.pause();
       // alert(video.currentSrc);
        //getVideo(this.src);
    });
    
    $("video").each(function(i, video) {
        alert(video.currentSrc);
        //getVideo(this.src);
    });
    
    
}); */

var rtmp_suffix = /^rtmp:\/\//;
var hls_suffix = /\.m3u8/;
var mp4_suffix = /\.(mp4|m4p|m4v|mov)/i;
var hds_suffix = /\.f4m/;
var dash_suffix = /\.mpd/;
var flv_suffix = /\.flv/;
var webm_suffix = /\.webm/;
/* AUDIO */
//var mp3_suffix = /\.mp3/;
var mpeg_suffix = /\.(mp3|m4a)/i;
var ogg_suffix = /\.ogg/;

//var youtube_suffix = /\.youtube.com/;
//var yt_suffix = /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/;
var...