The and marks indicate that the properties have respectively a getter and a setter.
Some properties only apply to the video player but I think you'll easily guess which ones.
The and marks indicate that the properties have respectively a getter and a setter.
Some properties only apply to the video player but I think you'll easily guess which ones.
/**
* @set currentTime
* @params {positive number}
* @description : set the media current time in seconds.
*/
//Set the current time to 25s.
myPlayer.currentTime = 25
/**
* @get currentTime
* @returns {number}
* @description : get the media current time in seconds.
*/
//Should returns 25
console.log(myPlayer.currentTime)
/**
* @set download
* @params {object}
* @description : set the download button properties (label / disabled / hidden / tooltip).
*/
//Changes the download button label and disables it.
myPlayer.download = {
label: 'Télécharger',
disabled: true
}
//Hides the download button.
myPlayer.download = {hidden: true}
All details here.
/**
* @set fullscreen
* @params {object}
* @description : set the fullscreen button properties (label / disabled / hidden / tooltip).
*/
//Changes the fullscreen button label and disables it.
myPlayer.fullscreen = {
label: {
on: 'Sortir du plein écran',
off: 'Plein écran'
},
disabled: true
}
//Hides the fullscreen button.
myPlayer.fullscreen = {hidden: true}
All details here.
/**
* @get init
* @returns {boolean}
* @description : returns true if the instance is initialized.
*/
/**
* @method hideControls()
* @description : Hides the video controls bar.
*/
//Listens to the amst__play event dispatched when media plays
//and immediately hides the controls bar
myPlayer.on('amst__play', function onFirstPlay() {
myPlayer.off('amst__play', onFirstPlay)
this.hideControls()//Hides the player controls
})
/**
* @set more
* @params {object}
* @description : set the more button properties (label / tooltip).
*/
//Changes the more button label.
myPlayer.more = {
label: {
on: 'Montrer moins',
off: 'Montrer plus'
}
}
All details here.
/**
* @set mute
* @params {object}
* @description : set the mute button properties (label / disabled / hidden / tooltip).
*/
//Changes the mute button label and disables it.
myPlayer.mute = {
label: {
on: 'Remettre le son',
off: 'couper le son'
},
disabled: true
}
//Hides the mute button.
myPlayer.mute = {hidden: true}
All details here.
/**
* @set muted
* @params {boolean}
* @description : Mutes/unmutes the volume media.
*/
/**
* @get muted
* @returns {boolean}
* @description : returns true if the volume media is muted.
*/
//Unmutes the media if it is muted.
if (myPlayer.muted) myPlayer.muted = false
/**
* @set next
* @params {object}
* @description : set the next button properties (label / disabled / hidden / tooltip).
*/
//Changes the next button label and disables it.
myPlayer.next = {
label: 'No more',
disabled: true
}
//Hides the next button.
myPlayer.next = {hidden: true}
All details here.
/**
* @method on
* @params {string} one event or multiple events separated by a space
* @params {function} function called when one of the events passed in first parameter occurs
* @description : set a listener to one or multiple events.
*/
//Listening to the amst__play event (emitted by the player when playback starts)
//and to the amst__pause event (emitted by the player when playback pauses)
myPlayer.on('amst__play amst__pause', _ => {
this.paused ? console.log('Player is paused') : console.log('Player is playing')
})
More on events here.
/**
* @method off
* @params {string} one event or multiple events separated by a space
* @params {function} function associated to the listener
* @description : remove a listener to one or multiple events.
*/
let count = 0
this.on('amst__play amst__pause', function just-a-silly-test(){
if (count < 2) {
this.paused ? console.log('Player is paused') : console.log('Player is playing')
count++
} else {
this.off('amst__play amst__pause', just-a-silly-test)
}
})
More on events here.
/**
* @get params
* @returns {object}
* @description : returns the current player parameters object.
*/
/**
* @method pause()
* @description : pauses the media.
*/
//Pauses the media if it is playing.
if (!myPlayer.paused) myPlayer.pause()
/**
* @get paused
* @returns {boolean}
* @description : returns true if the media is paused.
*/
//Plays the media if it is paused.
if (myPlayer.paused) myPlayer.play()
/**
* @method play()
* @description : plays the media.
*/
//Plays the media if it is paused.
if (myPlayer.paused) myPlayer.play()
/**
* @set playbackRate
* @params {number}
* @description : set the media playbackRate.
*/
/**
* @get playbackRate
* @returns {number}
* @description : get the media playbackRate.
*/
/**
* @set pip
* @params {object}
* @description : set the pip button properties (label / disabled / hidden / tooltip).
*/
//Changes the pip button label and disables it.
myPlayer.pip = {
label: {
on: 'Quitter le mode PIP',
off: 'Ouvrir PIP'
},
disabled: true
}
//Hides the pip button.
myPlayer.pip = {hidden: true}
All details here.
/**
* @set playPause
* @params {object}
* @description : set the playPause button properties (label / tooltip).
*/
//Changes the playPause button label.
myPlayer.pip = {
label: {
on: 'Arrêter',
off: 'Jouer'
},
}
All details here.
/**
* @set previous
* @params {object}
* @description : set the previous button properties (label / disabled / hidden / tooltip).
*/
//Changes the previous button label and disables it.
myPlayer.previous = {
label: 'No more',
disabled: true
}
//Hides the previous button.
myPlayer.previous = {hidden: true}
All details here.
/**
* @set settings
* @params {object}
* @description : set the settings button properties
* (hidden / qualityLabel / playbackRatesLabel / playbackRates / subsLabel).
*/
//Changes the settings button qualityLabel and subsLabel.
myPlayer.settings = {
qualityLabel: 'QUALITÉ',
subsLabel: 'SOUS-TITRES'
}
//Hides the settings button.
myPlayer.settings = {hidden: true}
All details here.
/**
* @method showControls()
* @description : Shows the video controls bar.
*/
/**
* @set src
* @params {string | array | object}
* @description : defines the media source(s) and all the options you need.
*/
//With a string
myPlayer.src = "path_to_media_file.mp4"
//With an array
myPlayer.src: [
{
src: 'path_to_media_file-360p.mp4',
quality: '360p'
},
{
src: 'path_to_media_file-480p.mp4',
quality: '480p'
},
{
src: 'path_to_media_file-720p.mp4',
quality: '720p',
default: true
},
{
src: 'path_to_media_file-1080p.mp4',
quality: '1080p'
},
]
//With an object
myPlayer.src = {
duration: 300,
src: [
{
src: 'path_to_media_file-360p.mp4',
quality: '360p'
},
{
src: 'path_to_media_file-480p.mp4',
quality: '480p'
},
{
src: 'path_to_media_file-720p.mp4',
quality: '720p',
default: true
},
{
src: 'path_to_media_file-1080p.mp4',
quality: '1080p'
},
],
thumbnails: {
src: 'path_to_thumbnails_file.jpg',
int: 2.12
},
subtitles: {
sources: [
{
src: 'path_to_subtitles_file-fr.vtt',
label: 'Français',
srclang: 'fr',
},
{
src: 'path_to_subtitles_file-en.vtt',
label: 'English',
srclang: 'en',
},
],
default: 'en'
}
}
/**
* @get src
* @returns {string}
* @description : returns the media source filepath.
*/
All details here.
/**
* @set subtitles
* @params {object}
* @description : set the subtitles button properties (label / disabled / hidden / tooltip / state)
* plus the subtitles files sources and the default language.
*/
/*
Changes the subtitles button label,
set subtitles sources,
default language to french,
and forces the button state to true
so subtitles are visible by default.
*/
myPlayer.subtitles = {
label: {
on: 'Cacher les sous-titres',
off: 'Montrer les sous-titres'
}
sources: [
{
src: 'path_to_the_english_subtitles_file.vtt',
srclang: 'en',
label: 'English',
},
{
src: 'path_to_the_french_subtitles_file.vtt',
srclang: 'fr',
label: 'Français',
},
],
default: 'fr',
state: true,
}
//Hides the subtitles button.
myPlayer.subtitles = {hidden: true}
All details here.
/**
* @method toggle()
* @description : toggles the media playback.
*/
//Plays the media if it is paused;
//pauses it if it's playing
myPlayer.toggle()
/**
* @set volume
* @params {number between 0 and 1}
* @description : set the media volume.
*/
/**
* @get volume
* @returns {number}
* @description : get the media volume.
*/