I am creating a custom controller for MP4 video on a web page. The controller includes a volume slider. Some of the videos that are to be played have no sound track. It would be
There might be a better way of doing this, although it's fairly simple just using regular javascript
for webkit
or mozilla
enabled browsers. webkit
utilizes this.audioTracks
and mozilla
uses this.mozHasAudio
respectively:
document.getElementById("video").addEventListener("loadeddata", function() {
if ('WebkitAppearance' in document.documentElement.style)
var hasAudioTrack = this.audioTracks.length;
else if (this.mozHasAudio)
var hasAudioTrack = 1;
if (hasAudioTrack > 0)
alert("audio track detected");
else
alert("audio track not detected");
});
There's also a function this.webkitAudioDecodedByteCount
, however, I've never had any luck making it work.