YouTip LogoYouTip

Event Oncanplaythrough

## HTML DOM oncanplaythrough Event The `oncanplaythrough` event occurs when the browser estimates that it can play the specified audio or video through to the end without having to stop for buffering. --- ## Definition and Usage The `oncanplaythrough` event is triggered when the media (audio/video) has loaded enough data to allow uninterrupted playback. The browser calculates this based on the current download speed and the duration of the media. ### Media Loading Lifecycle During the loading process of an audio or video file, events are fired in the following sequential order: 1. **`onloadstart`**: The browser begins looking for the media data. 2. **`ondurationchange`**: The duration of the media changes (becomes known). 3. **`onloadedmetadata`**: Metadata (like dimensions and duration) has been loaded. 4. **`onloadeddata`**: The browser has loaded the current playback frame. 5. **`onprogress`**: The browser is downloading the media data. 6. **`oncanplay`**: The browser can start playing the media, but may need to stop for further buffering. 7. **`oncanplaythrough`**: The browser estimates it can play the media to the end without pausing to buffer. --- ## Browser Support The numbers in the table specify the first browser version that fully supports this event. | Event | Chrome | Internet Explorer / Edge | Firefox | Safari | Opera | | :--- | :--- | :--- | :--- | :--- | :--- | | **`oncanplaythrough`** | Yes | 9.0 | Yes | Yes | Yes | --- ## Syntax You can register this event in three ways: ### In HTML: ```html ``` ### In JavaScript: ```javascript object.oncanplaythrough = function() { myScript(); }; ``` ### In JavaScript using `addEventListener()`: ```javascript object.addEventListener("canplaythrough", myScript); ``` > **Note:** The `addEventListener()` method is not supported in Internet Explorer 8 and earlier versions. --- ## Technical Details | Property | Value | | :--- | :--- | | **Bubbles** | No | | **Cancelable** | No | | **Event Type** | `Event` | | **Supported HTML Tags** | `
← C Pointer ArithmeticEvent Oncanplay β†’