fix: use bound arrow functions in classes
This commit is contained in:
@ -355,7 +355,7 @@ class Plyr {
|
||||
/**
|
||||
* Play the media, or play the advertisement (if they are not blocked)
|
||||
*/
|
||||
play() {
|
||||
play = () => {
|
||||
if (!is.function(this.media.play)) {
|
||||
return null;
|
||||
}
|
||||
@ -367,18 +367,18 @@ class Plyr {
|
||||
|
||||
// Return the promise (for HTML5)
|
||||
return this.media.play();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Pause the media
|
||||
*/
|
||||
pause() {
|
||||
pause = () => {
|
||||
if (!this.playing || !is.function(this.media.pause)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.media.pause();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get playing state
|
||||
@ -412,7 +412,7 @@ class Plyr {
|
||||
* Toggle playback based on current status
|
||||
* @param {Boolean} input
|
||||
*/
|
||||
togglePlay(input) {
|
||||
togglePlay = (input) => {
|
||||
// Toggle based on current state if nothing passed
|
||||
const toggle = is.boolean(input) ? input : !this.playing;
|
||||
|
||||
@ -421,42 +421,42 @@ class Plyr {
|
||||
}
|
||||
|
||||
return this.pause();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop playback
|
||||
*/
|
||||
stop() {
|
||||
stop = () => {
|
||||
if (this.isHTML5) {
|
||||
this.pause();
|
||||
this.restart();
|
||||
} else if (is.function(this.media.stop)) {
|
||||
this.media.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Restart playback
|
||||
*/
|
||||
restart() {
|
||||
restart = () => {
|
||||
this.currentTime = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Rewind
|
||||
* @param {Number} seekTime - how far to rewind in seconds. Defaults to the config.seekTime
|
||||
*/
|
||||
rewind(seekTime) {
|
||||
rewind = (seekTime) => {
|
||||
this.currentTime -= is.number(seekTime) ? seekTime : this.config.seekTime;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fast forward
|
||||
* @param {Number} seekTime - how far to fast forward in seconds. Defaults to the config.seekTime
|
||||
*/
|
||||
forward(seekTime) {
|
||||
forward = (seekTime) => {
|
||||
this.currentTime += is.number(seekTime) ? seekTime : this.config.seekTime;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Seek to a time
|
||||
@ -582,18 +582,18 @@ class Plyr {
|
||||
* Increase volume
|
||||
* @param {Boolean} step - How much to decrease by (between 0 and 1)
|
||||
*/
|
||||
increaseVolume(step) {
|
||||
increaseVolume = (step) => {
|
||||
const volume = this.media.muted ? 0 : this.volume;
|
||||
this.volume = volume + (is.number(step) ? step : 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Decrease volume
|
||||
* @param {Boolean} step - How much to decrease by (between 0 and 1)
|
||||
*/
|
||||
decreaseVolume(step) {
|
||||
decreaseVolume = (step) => {
|
||||
this.increaseVolume(-step);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set muted state
|
||||
@ -1033,18 +1033,18 @@ class Plyr {
|
||||
* Trigger the airplay dialog
|
||||
* TODO: update player with state, support, enabled
|
||||
*/
|
||||
airplay() {
|
||||
airplay = () => {
|
||||
// Show dialog if supported
|
||||
if (support.airplay) {
|
||||
this.media.webkitShowPlaybackTargetPicker();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle the player controls
|
||||
* @param {Boolean} [toggle] - Whether to show the controls
|
||||
*/
|
||||
toggleControls(toggle) {
|
||||
toggleControls = (toggle) => {
|
||||
// Don't toggle if missing UI support or if it's audio
|
||||
if (this.supported.ui && !this.isAudio) {
|
||||
// Get state before change
|
||||
@ -1074,34 +1074,34 @@ class Plyr {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add event listeners
|
||||
* @param {String} event - Event type
|
||||
* @param {Function} callback - Callback for when event occurs
|
||||
*/
|
||||
on(event, callback) {
|
||||
on = (event, callback) => {
|
||||
on.call(this, this.elements.container, event, callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add event listeners once
|
||||
* @param {String} event - Event type
|
||||
* @param {Function} callback - Callback for when event occurs
|
||||
*/
|
||||
once(event, callback) {
|
||||
once = (event, callback) => {
|
||||
once.call(this, this.elements.container, event, callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove event listeners
|
||||
* @param {String} event - Event type
|
||||
* @param {Function} callback - Callback for when event occurs
|
||||
*/
|
||||
off(event, callback) {
|
||||
off = (event, callback) => {
|
||||
off(this.elements.container, event, callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy an instance
|
||||
@ -1110,7 +1110,7 @@ class Plyr {
|
||||
* @param {Function} callback - Callback for when destroy is complete
|
||||
* @param {Boolean} soft - Whether it's a soft destroy (for source changes etc)
|
||||
*/
|
||||
destroy(callback, soft = false) {
|
||||
destroy = (callback, soft = false) => {
|
||||
if (!this.ready) {
|
||||
return;
|
||||
}
|
||||
@ -1208,15 +1208,13 @@ class Plyr {
|
||||
// Vimeo does not always return
|
||||
setTimeout(done, 200);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check for support for a mime type (HTML5 only)
|
||||
* @param {String} type - Mime type
|
||||
*/
|
||||
supports(type) {
|
||||
return support.mime.call(this, type);
|
||||
}
|
||||
supports = (type) => support.mime.call(this, type);
|
||||
|
||||
/**
|
||||
* Check for support
|
||||
|
Reference in New Issue
Block a user