Create a Player
Create a new player
You can easily create a new player that works in Elevate Web following these steps.
- Create a new class that represents your player.
- Implement the interface
PlayerInterface
and add the expected methods. - Implement the decorator
playerStaticMembers
and implement the expected static methods. - Register your player in
PlayerConfig.ts
and update the type for the player to be used.
Your player is now ready to be used!!!
Minimal Player implementation
To help you create a new player you can base your implementation on this minimal player setup.
import { CustomPlayer } from 'custom-player';
// CustomPlayer here represents any library used like shaka.Player
// would be for the Shaka Player implementation
@playerStaticMembers<CustomPlayer>()
export class NewPlayer implements PlayerInterface<CustomPlayer> {
// This method will be used to identify if the player supports
// a specific video type for playback.
public static getSupportedTypes = (): VideoType[] => {
return [];
};
getPlayer = () => {
throw new Error('Method "getPlayer" not implemented');
};
init = (init: InitParams) => {
throw new Error('Method "init" not implemented');
};
// Use a unique string name for your player
getName = () => 'CustomPlayer';
getCurrentPlaytime = () => {
throw new Error('Method "play" not implemented');
};
play = (startTime?: number) => {
throw new Error('Method "play" not implemented');
};
pause = () => {
throw new Error('Method "pause" not implemented');
};
load = (data: LoadConfig) => {
throw new Error('Method "load" not implemented');
};
seek = (time: number) => {
throw new Error('Method "seek" not implemented');
};
dispose = () => {
throw new Error('Method "dispose" not implemented');
};
}
You can then add the implementation of each method as you need.