Skip to content

Commit

Permalink
Merge pull request #157 from rtritto/improve-abstract-methods
Browse files Browse the repository at this point in the history
Add @abstract annotation and use common error message
  • Loading branch information
yoriiis authored Feb 22, 2025
2 parents d5cf59d + 2f0632e commit 051c53c
Showing 1 changed file with 25 additions and 39 deletions.
64 changes: 25 additions & 39 deletions src/core/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { formatVideoTime, isTouch } from 'shared/utils/utils.js'
* Vlitejs Player
* @module Vlitejs/Player
*/
export default class Player {
export default abstract class Player {
Vlitejs: any
type: string
media: HTMLAudioElement | HTMLVideoElement
Expand Down Expand Up @@ -87,100 +87,86 @@ export default class Player {
/**
* init
* Extends by the provider
* @abstract
*/
init() {
throw new Error('You have to implement the function "init".')
}
public abstract init(): void

/**
* waitUntilVideoIsReady
* Extends by the provider
* @abstract
*/
waitUntilVideoIsReady() {
throw new Error('You have to implement the function "waitUntilVideoIsReady".')
}
public abstract waitUntilVideoIsReady(): Promise<any>

/**
* getInstance
* Extends by the provider
* @abstract
*/
getInstance() {
throw new Error('You have to implement the function "getInstance".')
}
public abstract getInstance(): HTMLElement

/**
* getCurrentTime
* Extends by the provider
* @abstract
*/
getCurrentTime(): Promise<number> {
throw new Error('You have to implement the function "getCurrentTime".')
}
public abstract getCurrentTime(): Promise<number>

/**
* methodSeekTo
* Extends by the provider
* @abstract
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
methodSeekTo(newTime: number) {
throw new Error('You have to implement the function "methodSeekTo".')
}
public abstract methodSeekTo(newTime: number): void

/**
* getDuration
* Extends by the provider
* @abstract
*/
getDuration(): Promise<number> {
throw new Error('You have to implement the function "getDuration".')
}
public abstract getDuration(): Promise<number>

/**
* methodPlay
* Extends by the provider
* @abstract
*/
methodPlay() {
throw new Error('You have to implement the function "methodPlay".')
}
public abstract methodPlay(): void

/**
* methodPause
* Extends by the provider
* @abstract
*/
methodPause() {
throw new Error('You have to implement the function "methodPause".')
}
public abstract methodPause(): void

/**
* methodSetVolume
* Extends by the provider
* @abstract
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
methodSetVolume(newVolume: number) {
throw new Error('You have to implement the function "methodSetVolume".')
}
public abstract methodSetVolume(newVolume: number): void

/**
* methodGetVolume
* Extends by the provider
* @abstract
*/
methodGetVolume(): Promise<number> {
throw new Error('You have to implement the function "methodGetVolume".')
}
public abstract methodGetVolume(): Promise<number>

/**
* methodMute
* Extends by the provider
* @abstract
*/
methodMute() {
throw new Error('You have to implement the function "methodMute".')
}
public abstract methodMute(): void

/**
* methodUnMute
* Extends by the provider
* @abstract
*/
methodUnMute() {
throw new Error('You have to implement the function "methodUnMute".')
}
public abstract methodUnMute(): void

/**
* On the player is ready
Expand Down

0 comments on commit 051c53c

Please sign in to comment.