2

I want to show a video clip on my webpage.

I'm using the video tag but that doesn't show me the output.

I've attached two screenshots.

Please can someone tell me what's wrong with what I have done? enter image description here

enter image description here

1 Answers1

3

As mentioned in the comments, it seems quite possible this is due to a Firefox mp4/h.264 support issue.

There are actually some techniques you can use in your JavaScript to detect whether a video is playable and react accordingly - e.g. give the user a message or switch to a different video.

MediaSource.isTypeSupported()

The above will allow you do a check if a mime type is supported - it is 'experimental' so not supported by all browsers but is supported by Firefox 42.0 onwards. More info here:

H.264 codec support in Firefox is also a little confusing, I find, with different information in different places, but it certainly was the case and quite probably still is that support is reliant on the underlying system supporting the particular codec. Firefox does support a HTML5 mechanism that allows you to test at run time whether the video codec is supported:

function canPlayH264 () {
    var v = document.createElement('video');
    return !!(v.canPlayType && v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
};

More information here (under 'Detecting Playback):

As an aside, in case it is not clear, there are multiple different H.264 codec variants. This can cause confusion as one H.264 encoded video may be supported on a particular client device and another not. There is a nice explanation of how to read the codec info in this answer:

Community
  • 1
  • 1
Mick
  • 24,231
  • 1
  • 54
  • 120