Home Manual Reference Source Test
public class | source

Playback

You can directly use an instance of this class. playback

There should be one instance of Playback per page

This class is in charge of handling the playback of the active player it receives the commands from its Host and communicates the accordingly to the player.

It's also the responsible for exposing all the getters necessary to conform the Payload message.

By default all properties of Payload are extracted from the this.activePlayer although it is expected that this functionality is overridden by the providers.

Constructor Summary

Public Constructor
public

Create a new instance

Member Summary

Public Members
public

The current player being shown by the MPRIS2 interface

public

controls: Object<string, HTMLElement>

A dictionary of any controls extracted from the DOM

Method Summary

Public Methods
public

Check current page for 'next' functionality

public

Check current page for 'previous' functionality

public

Get the identity of playback, by default it is the site's domain

public

Get the loop status of playback

public

COMMAND Get active player's position

public

Get the rate of playback

public

One of PlaybackStatus.PLAYING or PlaybackStatus.PAUSED

public

Get the volume of playback

public

Get if the playback is shuffling between tracks

public

next()

Go to next media This should be implemented per provider

public

pause()

COMMAND Pause active player

public

play()

COMMAND Start to play active player

public

Go to previous This should be implemented per provider

public

seek(offset: number)

COMMAND Seek activePlayer to offset

public

Set the current active player

public

By default we don't support playlist looping (LoopStatus.PLAYLIST) so we force LoopStatus.TRACK loop if any loop other than LoopStatus.NONE is specified

public

setPosition(id: string, position: number)

COMMAND Set current position of active player

public

setRate(rate: number)

Set the rate of playback.

public

setShuffle(isShuffle: boolean)

Set the shuffle between tracks of playback

public

setVolume(volume: number)

Set the volume of playback

public

stop()

COMMAND Stop active player

public

COMMAND Toggle the fullscreen state

public

COMMAND Toggle between play and pause

Public Constructors

public constructor() source

Create a new instance

Public Members

public activePlayer: Player source

The current player being shown by the MPRIS2 interface

public controls: Object<string, HTMLElement> source

A dictionary of any controls extracted from the DOM

Public Methods

public canGoNext(): boolean source

Check current page for 'next' functionality

Return:

boolean

public canGoPrevious(): boolean source

Check current page for 'previous' functionality

Return:

boolean

public getIdentity(): null | string source

Get the identity of playback, by default it is the site's domain

Return:

null | string

public getLoopStatus(): LoopStatus source

Get the loop status of playback

Return:

LoopStatus

public getPosition(): null | number source

COMMAND Get active player's position

Return:

null | number

public getRate(): null | number source

Get the rate of playback

Return:

null | number

public getStatus(): string source

One of PlaybackStatus.PLAYING or PlaybackStatus.PAUSED

Return:

string

public getVolume(): null | number source

Get the volume of playback

Return:

null | number

public isShuffle(): boolean source

Get if the playback is shuffling between tracks

Return:

boolean

public next() source

Go to next media This should be implemented per provider

public pause() source

COMMAND Pause active player

public play() source

COMMAND Start to play active player

public previous() source

Go to previous This should be implemented per provider

public seek(offset: number) source

COMMAND Seek activePlayer to offset

Params:

NameTypeAttributeDescription
offset number

public setActivePlayer(player: Player) source

Set the current active player

Params:

NameTypeAttributeDescription
player Player

public setLoopStatus(status: LoopStatus) source

By default we don't support playlist looping (LoopStatus.PLAYLIST) so we force LoopStatus.TRACK loop if any loop other than LoopStatus.NONE is specified

Params:

NameTypeAttributeDescription
status LoopStatus

public setPosition(id: string, position: number) source

COMMAND Set current position of active player

Params:

NameTypeAttributeDescription
id string

the id of the player

position number

public setRate(rate: number) source

Set the rate of playback.

Params:

NameTypeAttributeDescription
rate number

Example:

playback.setRate(1.5);

public setShuffle(isShuffle: boolean) source

Set the shuffle between tracks of playback

Params:

NameTypeAttributeDescription
isShuffle boolean

public setVolume(volume: number) source

Set the volume of playback

Params:

NameTypeAttributeDescription
volume number

public stop() source

COMMAND Stop active player

public toggleFullScreen() source

COMMAND Toggle the fullscreen state

TODO:

  • test this works

public togglePlayback() source

COMMAND Toggle between play and pause