Home > Web Front-end > H5 Tutorial > body text

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

黄舟
Release: 2017-11-07 11:02:48
Original
3675 people have browsed it

Example

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

<video oncanplay="myFunction()">
Copy after login

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">
Copy after login

JavaScript:

object.oncanplay=function(){myScript};
Copy after login

JavaScript, use the addEventListener() method :

object.addEventListener("canplay", myScript);
Copy after login

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()">
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!