开发者

How to get the src for a video with multiple sources?

开发者 https://www.devze.com 2023-01-01 09:34 出处:网络
I\'d like to be able to get the src value that is actually used for a video element like the following:

I'd like to be able to get the src value that is actually used for a video element like the following:

<video>
  <source src="foo.mp4"  type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
  <source src="foo.webm" type='video/webm; codecs="vp8开发者_JS百科, vorbis"'>
  <source src="foo.ogv"  type='video/ogg; codecs="theora, vorbis"'>
</video>

In Firefox (at least), src is defined for the source elements but not for the video element.

How can I find which source is used?


I think I've answered my own question: the currentSrc property of the video element.

This works in Firefox, Safari (and Chrome, I assume) on Windows XP SP3, at least.

UPDATE: as was pointed out to me in the comments below, there is documentation of currentSrc in the WHATWG spec.

0

精彩评论

暂无评论...
验证码 换一张
取 消