Home  >  Article  >  Web Front-end  >  The oncanplay event triggered when the user can start playing video/audio in html5

The oncanplay event triggered when the user can start playing video/audio in html5

黄舟
黄舟Original
2017-11-07 11:02:483690browse

Example

Execute when the video (video) is ready to start playingJavaScript:

<video oncanplay="myFunction()">

Definition and usage

oncanplay event when the user can start Triggered when playing video/audio (audio/video).

During the video/audio (audio/video) loading process, the triggering sequence of events is as follows:

  1. onloadstart

  2. ondurationchange

  3. onloadedmetadata

  4. onloadeddata

  5. onprogress

  6. oncanplay

  7. oncanplaythrough

Browser support

The number in the table indicates the version number of the first browser that supports this event.

The oncanplay event triggered when the user can start playing video/audio in html5

Syntax

HTML:

<element oncanplay="myScript">

JavaScript:

object.oncanplay=function(){myScript};

JavaScript, use the addEventListener() method :

object.addEventListener("canplay", myScript);

Note: Internet Explorer 8 and earlier IE versions do not support the addEventListener() method.

Technical details

Whether bubbling is supported: No
Can be canceled : No
Event type: Event
Supported HTML tags:
##More examples

Examples

Execute JavaScript when audio is ready to play :

<audio oncanplay="myFunction()">


The above is the detailed content of The oncanplay event triggered when the user can start playing video/audio in html5. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn