Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking if a html5 video is ready

is there an JavaScript event triggered, if a HTML5 video is ready for playback?

like image 932
dantz Avatar asked Mar 03 '11 14:03

dantz


People also ask

Why is my video not working in HTML5?

If your browser error "HTML5 video file not found", it means that your browser is not up to date or website pages does not have a suitable video codec. It would help if you communicated with the developer to solve the issue and install all the required codecs.

What is the correct HTML5 element for playing video?

<video>: The Video Embed element. The <video> HTML element embeds a media player which supports video playback into the document.

Is MP4 an HTML5 video?

HTML5 Video Format for Desktop and Mobile StreamingThe HTML5 video format capabilities include three options to play: MP4, WebM, and Ogg. You should note that the Safari browser does not support Ogg, WebM is supported by only 58% of browsers, and MP4 is disabled by default in Firefox 24.


1 Answers

Just came across this question and although it is a little old I am posting this for future readers (who; like me, probably come from Google).

So as of today this is the event list for html5 media (according to W3C):

  • onabort : Script to be run on abort
  • oncanplay : Script to be run when a file is ready to start playing (when it has buffered enough to begin)
  • oncanplaythrough : Script to be run when a file can be played all the way to the end without pausing for buffering
  • ondurationchange : Script to be run when the length of the media changes
  • onemptied : Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects)
  • onended : Script to be run when the media has reach the end (a useful event for messages like "thanks for listening")
  • onerror : Script to be run when an error occurs when the file is being loaded
  • onloadeddata : Script to be run when media data is loaded
  • onloadedmetadata : Script to be run when meta data (like dimensions and duration) are loaded
  • onloadstart : Script to be run just as the file begins to load before anything is actually loaded
  • onpause : Script to be run when the media is paused either by the user or programmatically
  • onplay : Script to be run when the media is ready to start playing
  • onplaying : Script to be run when the media actually has started playing
  • onprogress : Script to be run when the browser is in the process of getting the media data
  • onratechange : Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode)
  • onreadystatechange : Script to be run each time the ready state changes (the ready state tracks the state of the media data)
  • onseeked : Script to be run when the seeking attribute is set to false indicating that seeking has ended
  • onseeking : Script to be run when the seeking attribute is set to true indicating that seeking is active
  • onstalled : Script to be run when the browser is unable to fetch the media data for whatever reason
  • onsuspend : Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason
  • ontimeupdate : Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media)
  • onvolumechange : Script to be run each time the volume is changed which (includes setting the volume to "mute")
  • onwaiting : Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data).

Dantz was looking for oncanplaythrough.

Hope this helps.

like image 100
MeanMatt Avatar answered Sep 19 '22 01:09

MeanMatt