- Version
- 1.0.0
- License
- MIT
- Requires
- object
- DomSmith
- Source
- ChromeCast.js, line 18
Constructor
new ChromeCast(player, parent, optionsopt)
Creates an instance of the ChromeCast component.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
player |
Player |
Reference to the main VisionPlayer instance. |
|||||||||
parent |
Controller |
Reference to the parent instance. |
|||||||||
options |
Object | optional |
Additional options.
|
Members
private #config :Object
Configuration for the ChromeCast component.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
showControllerButton
|
boolean | optional | true | If |
showMenuButton
|
boolean | optional | true | If |
lazyLoadLib
|
boolean | optional | true | If |
- Type
- Object
- Source
- ChromeCast.js, line 27
private #player :Player
Reference to the main player instance.
- Type
- Player
- Source
- ChromeCast.js, line 37
private #parent :Popup
Reference to the settings menu element.
- Type
- Popup
- Source
- ChromeCast.js, line 43
private #subscriptions :Array<number>
Holds tokens of subscriptions to player events, for later unsubscribe.
- Type
- Array<number>
- Source
- ChromeCast.js, line 49
private #apiKey :symbol
Secret key only known to the player instance and initialized components. Used to be able to restrict access to API methods in conjunction with secure mode.
- Type
- symbol
- Source
- ChromeCast.js, line 56
private #backdrop :DomSmith
DomSmith instance for the Cast backdrop.
- Type
- DomSmith
- Source
- ChromeCast.js, line 62
private #buttonMenu :DomSmith
private #buttonController :DomSmith
private #remote :Object
Status information of the remote cast device.
- Type
- Object
- Source
- ChromeCast.js, line 80
private #local :Object
Local copy of the player's functions for restoring after casting.
| Name | Type | Description |
|---|---|---|
seek
|
function | Original media.seek function of the player. |
play
|
function | Original media.play function of the player. |
pause
|
function | Original media.pause function of the player. |
volume
|
function | Original media.volume function of the player. |
mute
|
function | Original media.mute function of the player. |
load
|
function | Original media.load function of the player. |
lastSrc
|
string | The last set media source. |
- Type
- Object
- Source
- ChromeCast.js, line 101
private #castContext :Object
Instance of the Cast context.
- Type
- Object
- Source
- ChromeCast.js, line 107
private #castPlayer :Object
RemotePlayer instance for controlling the Cast device.
- Type
- Object
- Source
- ChromeCast.js, line 113
private #castPlayerController :Object
RemotePlayerController for monitoring changes to the RemotePlayer.
- Type
- Object
- Source
- ChromeCast.js, line 119
private #castSession
Cast session instance.
- Source
- ChromeCast.js, line 124
private #savedCurrentTime :number
Time snapshot used for resuming playback.
- Type
- number
- Source
- ChromeCast.js, line 130
private #volumeState :number
Volume state snapshot before casting.
- Type
- number
- Source
- ChromeCast.js, line 136
private #isSupported :boolean
Flag indicating if currently active media is supported for casting.
- Type
- boolean
- Source
- ChromeCast.js, line 142
Methods
private #addScripts()
Load Cast API Scripts from Google. This is only done after the user clicks the cast button.
- Source
- ChromeCast.js, line 264
private #onAvailable()
Initializes the Cast context and sets up necessary event listeners.
- Source
- ChromeCast.js, line 276
private #onMediaReady(src)
Checks if the current media source is supported for casting and enables or disables buttons accordingly.
| Name | Type | Description |
|---|---|---|
src |
string |
The current media source. |
- Listens
- media/ready
- Source
- ChromeCast.js, line 301
private #toggleCasting()
Toggles casting on or off based on the current status. In addition the google cast code is loaded if invoked for the first time.
- Source
- ChromeCast.js, line 316
private #onTogglePlay()
Toggles playback (play/pause).
- Source
- ChromeCast.js, line 327
async, private #startCasting() → void
Starts casting to a Chromecast device.
- Fires
- notification
- Returns
-
Returns when cast session has failed.
- Type void
- Source
- ChromeCast.js, line 344
private #generateRequest(sourceopt) → Object
Generates a media load request for casting. Also tries to include title, poster image and subtitles, if available.
| Name | Type | Attributes | Description |
|---|---|---|---|
source |
Object | optional |
The current media source. |
- Returns
-
The generated load request.
- Type Object
- Source
- ChromeCast.js, line 396
private #switchState()
Switches the player's state and binds remote functions.
- Source
- ChromeCast.js, line 465
private #stopCasting(endCastSessionopt)
Stops casting and restores the player to its original state.
| Name | Type | Attributes | Description |
|---|---|---|---|
endCastSession |
boolean | optional |
Indicates whether to also end the cast session. |
- Source
- ChromeCast.js, line 535
async, private #castStopped()
Handles the stopping of casting.
- Fires
- media/volumechange
- chromecast/stop
- Source
- ChromeCast.js, line 553
private #onCastEvent(event)
Handles cast events.
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
event |
Object |
The cast event from the google lib.
|
private #onSessionEvent(event)
Handles session events from the Cast context.
| Name | Type | Description |
|---|---|---|
event |
Object |
Session event from the google lib. |
- Source
- ChromeCast.js, line 714
private #onSubtitleChange(event)
Handles changes to subtitles.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
event |
Object |
Subtitle change event info.
|
- Listens
- subtitles/selected
- Source
- ChromeCast.js, line 737
private #onFontChange(size)
Handles changes to the subtitle font size.
| Name | Type | Description |
|---|---|---|
size |
string |
The new font size ('small', 'normal', 'big'). |
- Listens
- subtitles/fontsize
- Source
- ChromeCast.js, line 757
private #onPlaybackRateChange()
Handles changes to the playback rate.
- Listens
- media/ratechange
- Source
- ChromeCast.js, line 779
private #enable()
Enables the play button functionality. This method listens to canplay events in order to restore a usable state again when the player recovered from a media error (for example by loading another file).
- Listens
- media/canplay
- Source
- ChromeCast.js, line 802
private #disable()
Disables the button functionality. This method listens to media error events which cause the button to be disabled.
- Listens
- media/error
- data/nomedia
- Source
- ChromeCast.js, line 818
destroy()
Removes all events, subscriptions, and DOM nodes created by this component.
- Source
- ChromeCast.js, line 828
Events
chromecast/start
This event is fired when chromecast was started.
- Listeners
- PictureInPicture#disable
- VisualizerAmbient#stopLoop
- Source
- ChromeCast.js, line 848
chromecast/stop
This event is fired when chromecast was stopped.
- Listeners
- PictureInPicture#enable
- VisualizerAmbient#startLoop
- Source
- ChromeCast.js, line 853