How to Check If The Browser Can Play Mp4 via HTML5 Video Tag

How to detect if a video file is supported by the HTML5 video tag?

I've looked into it more, and canPlayType() can also contain the codec, so you can try:

canPlayType('video/mp4; codecs="avc1.42E01E"');

and

canPlayType('video/mp4; codecs="mp4a.40.2"');

separately for example

Detect if HTML5 Video element is playing

Note : This answer was given in 2011. Please check the updated documentation on HTML5 video before proceeding.

If you just want to know whether the video is paused, use the flag stream.paused.

There is no property for a video element in getting its playing status. But there is one event "playing" which will be triggered when it starts to play. An Event called "ended" is also triggered when it stops playing.

So the solution is:

  1. Declare one variable videoStatus.
  2. Add event handlers for different events of video.
  3. Update videoStatus using the event handlers.
  4. Use videoStatus to identify the status of the video.

This page will give you a better idea about video events. Play the video on this page and see how the events are triggered.

http://www.w3.org/2010/05/video/mediaevents.html

HTML5 Video Tag Not Displayed In Compatible Browser

I'd recommend you to read http://goo.gl/4NwNP7 and use flash as fallback option always.

You can't achieve 100% cross-browser solution with only using HTML5 video tag.

Also in your case, one of solutions is https://stackoverflow.com/a/9349984/800639

How to determine if the guest web browser supports html5 <video>

<video> tags allow content between the tags. Only when the browser does not support <video> will the content within be rendered on the page.

<video> 
<source ogg>
<source mp4>
<embed flv /> <!-- embed only rendered if video not supported-->
</video>


Related Topics



Leave a reply



Submit