Page
Direct Subclass:
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 |
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 |
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 |
setActivePlayer(player: Player) Set the playback's active player |
Public Constructors
Public Members
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.
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 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:
Name | Type | Attribute | Description |
element | Element | ||
options | MutationObserverInit |
public observeForMedia(element: Element) source
Set element to be observed by this._mediaObserver
Params:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
mutations | Array<MutationRecord> |