Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
102 views
in Technique[技术] by (71.8m points)

javascript - Checking if a html5 video is ready

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

question from:https://stackoverflow.com/questions/5181865/checking-if-a-html5-video-is-ready

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...