Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get video tag src using JavaScript?

I am trying to get video URL using JavaScript. Code is ...

<div class="flideo">
    <video x-webkit-airplay="allow" preload="" src="http://pdl.vimeocdn.com/80388/120/224743790.mp4?token2=1394169786_c1f036dda110a70d45fd824ec6692b94&amp;aksessionid=e766a96a167c751e" poster=""></video>
</div>

Thanks..

like image 773
Win More Avatar asked Mar 07 '14 05:03

Win More


People also ask

How can use video src tag in HTML?

Attribute Values The URL of the video file. Possible values: An absolute URL - points to another web site (like src="http://www.example.com/movie.ogg") A relative URL - points to a file within a web site (like src="movie.

How do I show video tags in HTML?

The <video> tag contains one or more <source> tags with different video sources. The browser will choose the first source it supports. The text between the <video> and </video> tags will only be displayed in browsers that do not support the <video> element.

How do I change the src of a video tag?

To change source on HTML5 video tag with JavaScript, we an set the src property of the video element. const changeSource = (url) => { const video = document. getElementById("video"); video. src = url; video.


1 Answers

The accepted answer didn't work for me, I had to change src to currentSrc, i.e.:

var videoTags = document.getElementsByTagName('video')
 for( var i = 0; i < videoTags.length; i++ ){
      alert( videoTags.item(i).currentSrc )
}
like image 69
Pedro Lobito Avatar answered Oct 13 '22 12:10

Pedro Lobito