1.0.0 • Published 2 years ago

playerapi v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

WARNING: the scripts in package.json not setup and therefore not working!

Private variables

configUrl: string;
config: PlayerConfigType;

listeners: Array<ListenerType>;
listenersAdded: boolean;

playerCommands: queue;
playerToolkit: PlayerToolkit;


state: {
    isStarting: boolean = false,
    isStopping: boolean = false,
    isPlaying: boolean = false,
    isInitialised: boolean = false,
}

Listener type

type Listener {
		event: PlayerToolkitEventTypes;
		callback: (event) => unknown;
	}

Function init

init(configUrl: string, listeners: Array<ListenerType>, autoPlay: boolean = true): Promise<void> => new Promise(() {
    - fetch config via configUrl
    - load script/apply toolkit to DOM (toolkitUrl)
    - initialize Toolkit with config and adding autoPlay variable
    - register all listeners with callbacks
    - starts the playerCommands queue
})

Function start

start(contentResource: ContentResourceType, videoElement: HTMLVideoElement = null): void => {
    - pushes following command to playerCommands
        - calls start on playerToolkit
        - synchronizes isPlaying state
        - awaits playerready event
}

Function stop

stop(): void => {
    - pushes following command to playerCommands
        - calls stop on playerToolkit
        - synchronizes isPlaying state
};

Function seek

seek(position: number): void => {
    - call seek on playerToolkit.WebPlayer for the given position
};

Function play

play(): boolean => {
    - call play on playerToolkit.WebPlayer
    - returns the synchronized isPlaying state
};

Function pause

pause(): boolean => {
    - call pause on playerToolkit.WebPlayer
    - returns the synchronized isPlaying state
};

Function getDuration

getDuration(): number => {
    - tries to call getDuration on playerToolkit.WebPlayer
    - returns the duration or 0 if error was caught

Function getCurrentTime

getCurrentTime(): number => {
    - tries to call getCurrentTime on playerToolkit.WebPlayer
    - returns the current time or 0 if error was caught
};

Function getCurrentTimeWithoutAds

getCurrentTimeWithoutAds(): number => {
    - tries to call getCurrentTimeWithoutAds on playerToolkit
    - returns: 
        - the current time without ads OR 
        - null if playerToolkit.AdTracker does not exist OR 
        - null if error was caught
};

Function getDurationWithoutAds

getDurationWithoutAds(): number => {
    - tries to call getDurationWithoutAds on playerToolkit
    - returns: 
        - the duration without ads OR 
        - null if playerToolkit.AdTracker does not exist OR 
        - 0 if error was caught
};

Function destroy

destroy(): void => {
    - ends the playerCommands queue
    - destroy playerToolkit
};

Function togglePlayback

togglePlayback(): boolean => {
    - pause WebPlayer if isPlaying is true
    - play WebPlayer if isPlaying is false
    - returns the synchronized isPlaying state
}

Function isPlaying

isPlaying(): boolean => {
    - return the isPlaying state
}

Function isInitialised

isInitialised(): boolean => {
    - return the isInitialised state
}
1.0.0

2 years ago

0.1.0

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago