0

I'm trying to detect if a local file (or blob), that I don't know the type, can be play by the browser...

I can actually do this :

  • By using a setTimeout and onload, but we never now when the onload funtion will be fired...
  • By Using the file.type but it only uses the file name...
  • By using the readArrayBuffer, no way with big file...

Is there any way to detect if a file from the input file button can be play or not ?

alexino2
  • 101
  • 10
  • Possible duplicate of [Play local (hard-drive) video file with HTML5 video tag?](http://stackoverflow.com/questions/8885701/play-local-hard-drive-video-file-with-html5-video-tag) – Alvaro Montoro Nov 14 '15 at 18:14

1 Answers1

0

You could do some sort of analysis of the file, mimicking the type of functionality that ffprove provides, and then compare the deduced video characteristics with a known map of video characteristics per browser type.

The file type, as you point out is only a crude guide - for example mp4 files may have many different 'characteristics' such as encoding format etc, some of which will be supported on some platforms and not on others.

However, this will be complex to implement and you will constantly have to update the mapping of video types support to browser types as this evolves over time.

The simplest and most reliable way is, as I think you are saying in your question, to try to play the video and then catch any errors generated.

Mick
  • 24,231
  • 1
  • 54
  • 120