Home Manual Reference Source Test
public class | source

Page

You can directly use an instance of this class. page

Direct Subclass:

NetflixPage, YouTubePage

A class in charge of detecting new HTMLMediaElements in current page and registering them as players.

The expected usage is call checkForMediaElements and observeForMedia upon window.load event.

Constructor Summary

Public Constructor
public

constructor(document: Document, playback: Playback, host: Host)

Member Summary

Public Members
public

document: Document

The current document to keep as context

public

elements: Object<string, HTMLElement>

Upon load of a page this property can be used by providers to cache html elements that are likely to be used repeatedly.

public

Current Host to trigger changes

public

Current Playback on the page

public

An array holding all Players present in the page

Private Members
private

_changesObserver: MutationObserver

An observer to trigger change events on the host use observeForChanges to add elements

private

_mediaObserver: MutationObserver

An observer for added media elements use observeForMedia to observer elements

Method Summary

Public Methods
public

Search DOM for any <video> or <audio> elements

public

Get the playbacks active player

public

Get the page's favicon

public

Get the page's title

public

observeForChanges(element: Element, options: MutationObserverInit)

Set element to be observed by this._changesObserver by default check for any changes to itself or it's children

public

observeForMedia(element: Element)

Set element to be observed by this._mediaObserver

public

onMutate(mutations: Array<MutationRecord>)

Callback called by this._mediaObserver Given an array of mutations check if there where any added nodes that are media

public

registerPlayer(element: *): boolean

Take the element and add it to the list of players if it's not already there

Use when detecting a new element on the DOM

If the element is playing it will be set as the active player.

public

Set the playback's active player

Public Constructors

public constructor(document: Document, playback: Playback, host: Host) source

Params:

NameTypeAttributeDescription
document Document
playback Playback
host Host

Public Members

public document: Document source

The current document to keep as context

public elements: Object<string, HTMLElement> source

Upon load of a page this property can be used by providers to cache html elements that are likely to be used repeatedly.

See:

public host: Host source

Current Host to trigger changes

public playback: Playback source

Current Playback on the page

public players: Array<Player> source

An array holding all Players present in the page

Private Members

private _changesObserver: MutationObserver source

An observer to trigger change events on the host use observeForChanges to add elements

private _mediaObserver: MutationObserver source

An observer for added media elements use observeForMedia to observer elements

Public Methods

public checkForMediaElements() source

Search DOM for any <video> or <audio> elements

public getActivePlayer(): Player source

Get the playbacks active player

Return:

Player

public getIcon(): string source

Get the page's favicon

Return:

string

public getTitle(): null | string source

Get the page's title

Return:

null | string

public observeForChanges(element: Element, options: MutationObserverInit) source

Set element to be observed by this._changesObserver by default check for any changes to itself or it's children

Params:

NameTypeAttributeDescription
element Element
options MutationObserverInit

public observeForMedia(element: Element) source

Set element to be observed by this._mediaObserver

Params:

NameTypeAttributeDescription
element Element

public onMutate(mutations: Array<MutationRecord>) source

Callback called by this._mediaObserver Given an array of mutations check if there where any added nodes that are media

Params:

NameTypeAttributeDescription
mutations Array<MutationRecord>

public registerPlayer(element: *): boolean source

Take the element and add it to the list of players if it's not already there

Use when detecting a new element on the DOM

If the element is playing it will be set as the active player.

Params:

NameTypeAttributeDescription
element *

Return:

boolean

public setActivePlayer(player: Player) source

Set the playback's active player

Params:

NameTypeAttributeDescription
player Player