I’m setting up analytics on our html5 videos. Since Chrome, Firefox, etc. currently play different file types (but may change in the future), is there a way with Javascript to get the video source that’s actually being played by the browser?
Markup:
<video class="myclass">
<source src="myvid.mp4" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2" />
<source src="myvid.webm" type="video/webm; codecs="vp8, vorbis" />
<source src="myvid.ogv" type="video/ogg; codecs="theora, vorbis" />
</video>
This is not exemplary coding style, but this works for me and should be enough to get you started:
Basically, you want the
currentSrcproperty after the metadata has been loaded.