Menu

Events

thisPlayer provides HTML5 media element based events as well as own custom events. Finally you have cool list of thisPlayer events which you can use with on() method.

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.

load

This event fires when media sources are loaded enough to start playback. Provides an event argument.

controlstoggle

Fires 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.

contextmenu

Fires when custom context menu toggles and provides an event argument. For more details visit context menus page.

loadstart

Fires when media begins loading. And it has event argument.

canplay

Sent when there is loaded enough data for few of next frames. Have an event argument in callback function.

canplaythrough

Fires when assuming the download rate the media can be played without interruption. Has an event callback argument.

loadedmetadata

Event fires when metadata of the current media file such as duration, volume etc are loaded. Provides an event argument in callback function.

play

Sent when player starts playback after having been paused. Provides an event argument of callback function.

pause

Fires when player paused. provides an event argument in callback function.

timeupdate

Fires when current time is changing. Also provides an event argument in callback function.

playing

It'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.

buffering

Fires when new part of media is downloaded, all information about downloaded parts is in event argument of callback function.

seeking

Fires when player is seeking. Provides an event and current time arguments into callback function.

seeked

Fires when seek operation finishes. Has an event and current time arguments into the callback function.

ended

Fires when playback is ended. Provides an event argument into the callback function.

durationchange

Fires when media duration is discovered or the duration is changed. Has an event argument in callback function.

volumechange

Sent when volume is changed also when mute or unmute. Provides an event and current volume arguments in callback function.

mutechange

Fires on mute or unmute. Provides current mute state argument in callback function.

fullscreenchange

Fires when fullscreen mode changes. Provides an event and fullscreen mode arguments in callback function.

qualitychange

Fires 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.

texttrackchange

Fires 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.

cuechange

Fires when text track cue changes. Provides text track cues object, current cue object and current time arguments in callback function.

waiting

Fires when player is waiting/loading or playback is delayed for some reason. Has an event argument in callback function.

emptied

Fires when media has become empty. For example when media beings reload when it was already loaded. Provides an event argument in callback function.

stalled

Fires when can not fetch media. Provides an event argument in callback function.

suspend

Fires when media downloading is suspended because of some reason or download is completed. Provides an event argument in callback function.

error

Fires 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.