Menu

Methods

thisPlayer provides several methods for better control on it. Below you can get know how each methods are working and how to use them.

Lets say that code below is real thisPlayer setup:

var tp = thisPlayer({
    container: '#video-player',
    resources: '/your-folder/your-video.mp4'
});

As you can see we have player object into the tp variable

So now see how each method will work for tp thisPlayer object:

load()

This method forces player to fully load/realize all provided media files. Calling the method is looking like that tp.load();

remove()

The method tp.remove(); removes thisPlayer but keeps the HTML5 media (<video> or <audio>) element in place of thisPlayer. but if you want to destroy thisPlayer with HTML5 media element use true as argument of method like that tp.remove(true);

build(options)

Method rebuilds/regenerates thisPlayer with new options. It keeps old options but rewrites new ones over them. You can pass new options using this method like that:

tp.build({
    autoplay: true,
    ratio: '7/4'
});

If new options are not provided tp.build(); then just new player will be generated with no changes.

on()

This is for attaching events. Method attaches an event and callback to the player. For example:

tp.on('play', function(){
    window.alert('Yayyy player start playback');
    //the callback function
});

For detailed information about events and this method take a look on thisPlayer events page.

play()

It makes player start playback if it is paused or eve not started. tp.play();

pause()

Makes player paused if it plays. Very simply just call the method. tp.pause();

stop()

This method is different than pause(). It stops player tp.stop();

time()

If no argument, this method returns the current time of the player in seconds tp.time();. But it sets the time to the player if you provide an integer argument tp.time(50); is seconds too.

volume()

If no argument it returns current volume of the player tp.volume(); from 0 to 1. If you set a number argument from 0 to 1 tp.volume(0.6); it sets the volume to the player.

mute()

Method returns whether is player muted or not - when you do not set any argument tp.mute();. If you set boolean argument tp.mute(true); it makes player muted but if you set tp.mute(false); it makes player unmuted.

quality()

If no argument it returns current quality object ID tp.quality(); if qualities are available. Set quality ID as argument of method to change the quality mode. For more and detailed information see page about multiple qualities which explains how to use that method most clearly.

texttrack()

This method returns current text track URL if no argument tp.texttrack();. And sets new text track if you set the URL of the existing text track object as argument of method. See detailed information about that on text tracks page.