How to attache an event to thisPlayer
Attaching the events to thisPlayer is pretty easy and pretty similar of another libraries. So lets see an example:
Generate the player like so:
var tp = thisPlayer({
container: '#player-container',
resources: '/your-folder/your-video.mp4'
});
As you can see we have instance of thisPlayer in tp variable. Now lets attach the play event to it.
Attaching the event is looking like that:
tp.on('play', function(e){
// [e] is a provided event argument by callback
// Your custom code here :)
});
Now try and attache seeking event to thisPlayer:
tp.on('seeking', function(e, ct){
// [e] is a provided event argument by callback function
// [ct] is a provided current time argument by callback function
// Your custom code here :)
});
So as you can see attaching events to thisPlayer and getting its callback arguments is pretty easy. Now go ahead and take a look a complete list of thisPlayer events with these descriptions.
loadThis event fires when media sources are loaded enough to start playback. Provides an event argument.
controlstoggleFires when controls bar disappears or appears and provides an argument with boolean value true if controls bar is shown and false if it is hidden.
contextmenuFires when custom context menu toggles and provides an event argument. For more details visit context menus page.
loadstartFires when media begins loading. And it has event argument.
canplaySent when there is loaded enough data for few of next frames. Have an event argument in callback function.
canplaythroughFires when assuming the download rate the media can be played without interruption. Has an event callback argument.
loadedmetadataEvent fires when metadata of the current media file such as duration, volume etc are loaded. Provides an event argument in callback function.
playSent when player starts playback after having been paused. Provides an event argument of callback function.
pauseFires when player paused. provides an event argument in callback function.
timeupdateFires when current time is changing. Also provides an event argument in callback function.
playingIt's different event than timeupdate. its firing just when player is playing. Also it provides an event argument and current time argument of the callback function.
bufferingFires when new part of media is downloaded, all information about downloaded parts is in event argument of callback function.
seekingFires when player is seeking. Provides an event and current time arguments into callback function.
seekedFires when seek operation finishes. Has an event and current time arguments into the callback function.
endedFires when playback is ended. Provides an event argument into the callback function.
durationchangeFires when media duration is discovered or the duration is changed. Has an event argument in callback function.
volumechangeSent when volume is changed also when mute or unmute. Provides an event and current volume arguments in callback function.
mutechangeFires on mute or unmute. Provides current mute state argument in callback function.
fullscreenchangeFires when fullscreen mode changes. Provides an event and fullscreen mode arguments in callback function.
qualitychangeFires when player quality changes just when multiple qualities mode is available. Provides thisPlayer qualities object and current quality ID arguments in event callback function. For more information regarding - visit multiple qualities page.
texttrackchangeFires when text track changes. Provides whole text tracks object and current text track item object arguments in callback function. For more information visit text tracks page.
cuechangeFires when text track cue changes. Provides text track cues object, current cue object and current time arguments in callback function.
waitingFires when player is waiting/loading or playback is delayed for some reason. Has an event argument in callback function.
emptiedFires when media has become empty. For example when media beings reload when it was already loaded. Provides an event argument in callback function.
stalledFires when can not fetch media. Provides an event argument in callback function.
suspendFires when media downloading is suspended because of some reason or download is completed. Provides an event argument in callback function.
errorFires in case of some error. When player was not generated or there was any other error with media file etc. Provides an event argument in callback function.
