# Events
We support the standard Video Runtime Events;
<template>
<div class="player-container">
<vue-core-video-player @loadedmetadata="loaded" @play="playFunc" @pause="pauseFunc" src="./videos/your_video.mp4"></vue-core-video-player>
</div>
<template>
<script>
export default {
methods: {
loaded () {
// your code
},
playFunc () {
// your code
},
pauseFunc () {
// your code
}
}
}
# Basic Events
# LIFECYCYLE Hooks
lifecycle_before_createindicates player starts to create the Core instance.lifecycle_createdindicates player has created the Core instancelifecycle_parsedindicates the player has parsed the video source.lifecycle_destroyedindicates the player start destroy the instance.lifecycle_destroyedindicates the player has destroyed the instance.
# PLayback Events
We follow the W3C Media Events API. And you can read MDN to know the details. There are some useful events you may use in your project,
playindicates the player start play or from to pause to the play state viaplay()method.pausemeans the player stop play the video.progressindicate the player is downloading the media contents.loadeddataindicates the player has loaded the first frame.canplayis sent when enough data is available that the media can be played, at least for a couple of frames.durationchangeis sent when the readyState changes to HAVE_ENOUGH_DATA, indicating that the entire media can be played without interruption, assuming the download rate remains at least at the current levelendedindicates the player ended the video.timeupdateThe time indicated by the element's currentTime attribute has changedseekedis sent when a seek operation completes.
There are also many other normal events about media, we recommended MDN-Media_Event for you.
# Playback Error
Playback errors sometime happen and we provide error code for developers and users to get some reasons.
<template>
<div class="player-container">
<vue-core-video-player @error="errorHandle" src="./videos/your_video.mp4"></vue-core-video-player>
</div>
<template>
<script>
export default {
methods: {
errorHandle (e) {
// handle error
},
}
}
The event structure contains the error object and error code
{
code: xxx
target: videlEr
}
- 2404 Source not found
- 2502 Media Network Error
- 2503 Video Cannot Decode
- 2504 Video Cannot Play
- 2701 Parse Error
- 2801 Not found reason
# UI Events
ui_dashboard_showindicates the player shows the dashboard.ui_dashboard_hideindicates the player hide the dashboard.
This is Full Events Code And we has export the event module for developers to develop some third plugins.
import { EVENTS } from 'vue-core-video-player'
player.on(EVENTS.PLAY, () => {
// ...
})