From 9df52d660feb722404be00a50f3c8a612bec1c15 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 17 Aug 2021 14:42:53 +0200 Subject: Migrate client to eslint --- client/src/standalone/player/player.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'client/src/standalone/player/player.ts') diff --git a/client/src/standalone/player/player.ts b/client/src/standalone/player/player.ts index 9776fda12..bbe37a42b 100644 --- a/client/src/standalone/player/player.ts +++ b/client/src/standalone/player/player.ts @@ -17,7 +17,7 @@ const PASSTHROUGH_EVENTS = [ */ export class PeerTubePlayer { - private eventRegistrar: EventRegistrar = new EventRegistrar() + private readonly eventRegistrar: EventRegistrar = new EventRegistrar() private channel: Channel.MessagingChannel private readyPromise: Promise @@ -31,8 +31,8 @@ export class PeerTubePlayer { * @param scope */ constructor ( - private embedElement: HTMLIFrameElement, - private scope?: string + private readonly embedElement: HTMLIFrameElement, + private readonly scope?: string ) { this.eventRegistrar.registerTypes(PASSTHROUGH_EVENTS) @@ -90,6 +90,7 @@ export class PeerTubePlayer { /** * Tell the embed to change the audio volume + * * @param value A number from 0 to 1 */ async setVolume (value: number) { @@ -98,14 +99,16 @@ export class PeerTubePlayer { /** * Get the current volume level in the embed. + * * @param value A number from 0 to 1 */ async getVolume (): Promise { - return this.sendMessage('getVolume') + return this.sendMessage('getVolume') } /** * Tell the embed to change the current caption + * * @param value Caption id */ async setCaption (value: string) { @@ -116,11 +119,12 @@ export class PeerTubePlayer { * Get video captions */ async getCaptions (): Promise { - return this.sendMessage('getCaptions') + return this.sendMessage('getCaptions') } /** * Tell the embed to seek to a specific position (in seconds) + * * @param seconds */ async seek (seconds: number) { @@ -143,21 +147,21 @@ export class PeerTubePlayer { * resolutions change. */ async getResolutions (): Promise { - return this.sendMessage('getResolutions') + return this.sendMessage('getResolutions') } /** * Retrieve a list of available playback rates. */ async getPlaybackRates (): Promise { - return this.sendMessage('getPlaybackRates') + return this.sendMessage('getPlaybackRates') } /** * Get the current playback rate. Defaults to 1 (1x playback rate). */ async getPlaybackRate (): Promise { - return this.sendMessage('getPlaybackRate') + return this.sendMessage('getPlaybackRate') } /** @@ -188,7 +192,7 @@ export class PeerTubePlayer { * Get video position currently played (starts from 1) */ async getCurrentPosition () { - return this.sendMessage('getCurrentPosition') + return this.sendMessage('getCurrentPosition') } private constructChannel () { @@ -201,8 +205,8 @@ export class PeerTubePlayer { } private prepareToBeReady () { - let readyResolve: Function - let readyReject: Function + let readyResolve: () => void + let readyReject: () => void this.readyPromise = new Promise((res, rej) => { readyResolve = res @@ -219,7 +223,8 @@ export class PeerTubePlayer { private sendMessage (method: string, params?: TIn): Promise { return new Promise((resolve, reject) => { this.channel.call({ - method, params, + method, + params, success: result => resolve(result), error: error => reject(error) }) @@ -228,4 +233,4 @@ export class PeerTubePlayer { } // put it on the window as well as the export -(window[ 'PeerTubePlayer' ] as any) = PeerTubePlayer +(window['PeerTubePlayer'] as any) = PeerTubePlayer -- cgit v1.2.3