Constructor
new CastProxy(videonon-null, playernon-null, receiverAppId)
A proxy to switch between local and remote playback for Chromecast in a way
that is transparent to the app's controls.
Parameters:
Name | Type | Description |
---|---|---|
video |
HTMLMediaElement | The local video element associated with the local Player instance. |
player |
shaka.Player | A local Player instance. |
receiverAppId |
string | The ID of the cast receiver application. |
- Implements:
- Extends:
- Source:
Members
-
dispatchTarget :EventTarget
-
The target of all dispatched events. Defaults to |this|.
Type:
- EventTarget
- Inherited From:
- Source:
-
(private) eventManager_ :shaka.util.EventManager
-
Type:
- Source:
-
(private, non-null) listeners_ :shaka.util.MultiMap.<shaka.util.FakeEventTarget.ListenerType>
-
Type:
- Inherited From:
- Source:
-
(private) localPlayer_ :shaka.Player
-
Type:
- Source:
-
(private) localVideo_ :HTMLMediaElement
-
Type:
- HTMLMediaElement
- Source:
-
(private) playerEventTarget_ :shaka.util.FakeEventTarget
-
Type:
- Source:
-
(private) playerProxy_ :Object
-
Type:
- Object
- Source:
-
(private) sender_ :shaka.cast.CastSender
-
Type:
- Source:
-
(private) videoEventTarget_ :shaka.util.FakeEventTarget
-
Type:
- Source:
-
(private) videoProxy_ :Object
-
Type:
- Object
- Source:
Methods
-
addEventListener(type, listener, opt_capturingopt)
-
Add an event listener to this object.
Parameters:
Name Type Attributes Description type
string The event type to listen for. listener
shaka.util.FakeEventTarget.ListenerType The callback or listener object to invoke. opt_capturing
boolean <optional>
Ignored. FakeEventTargets do not have parents, so events neither capture nor bubble. - Inherited From:
- Source:
-
canCast() → {boolean}
-
- Source:
Returns:
True if the cast API is available and there are receivers.- Type
- boolean
-
cast() → (non-null) {Promise}
-
- Source:
Returns:
Resolved when connected to a receiver. Rejected if the connection fails or is canceled by the user.- Type
- Promise
-
destroy() → (non-null) {Promise}
-
Destroys the proxy and the underlying local Player.
- Implements:
- Source:
Returns:
- Type
- Promise
-
dispatchEvent(eventnon-null) → {boolean}
-
Dispatch an event from this object.
Parameters:
Name Type Description event
Event The event to be dispatched from this object. - Inherited From:
- Source:
Returns:
True if the default action was prevented.- Type
- boolean
-
(private) getInitState_() → {shaka.cast.CastUtils.InitStateType}
-
- Source:
Returns:
initState Video and player state to be sent to the receiver. -
getPlayer() → {shaka.Player}
-
Get a proxy for the Player that delegates to local and remote Player objects as appropriate.
- Source:
Returns:
- Type
- shaka.Player
-
getVideo() → {HTMLMediaElement}
-
Get a proxy for the video element that delegates to local and remote video elements as appropriate.
- Source:
Returns:
- Type
- HTMLMediaElement
-
(private) init_()
-
Initialize the Proxies and the Cast sender.
- Source:
-
isCasting() → {boolean}
-
- Source:
Returns:
True if we are currently casting.- Type
- boolean
-
(private) onCastStatusChanged_()
-
Dispatch an event to notify the app that the status has changed.
- Source:
-
(private) onRemoteEvent_(targetName, eventnon-null)
-
Parameters:
Name Type Description targetName
string event
shaka.util.FakeEvent - Source:
-
(private) onResumeLocal_()
-
Transfer remote state back and resume local playback.
- Source:
-
(private) playerProxyGet_(name) → {?}
-
Parameters:
Name Type Description name
string - Source:
Returns:
- Type
- ?
-
(private) playerProxyLocalEvent_(eventnon-null)
-
Parameters:
Name Type Description event
Event - Source:
-
receiverName() → {string}
-
- Source:
Returns:
The name of the Cast receiver device, if isCasting().- Type
- string
-
removeEventListener(type, listener, opt_capturingopt)
-
Remove an event listener from this object.
Parameters:
Name Type Attributes Description type
string The event type for which you wish to remove a listener. listener
shaka.util.FakeEventTarget.ListenerType The callback or listener object to remove. opt_capturing
boolean <optional>
Ignored. FakeEventTargets do not have parents, so events neither capture nor bubble. - Inherited From:
- Source:
-
setAppData(appData)
-
Set application-specific data.
Parameters:
Name Type Description appData
Object Application-specific data to relay to the receiver. - Source:
-
suggestDisconnect()
-
Show a dialog where user can choose to disconnect from the cast connection.
- Source:
-
(private) videoProxyGet_(name) → {?}
-
Parameters:
Name Type Description name
string - Source:
Returns:
- Type
- ?
-
(private) videoProxyLocalEvent_(eventnon-null)
-
Parameters:
Name Type Description event
Event - Source:
-
(private) videoProxySet_(name, value)
-
Parameters:
Name Type Description name
string value
? - Source:
Events
-
CastStatusChangedEvent
-
Fired when cast status changes. The status change will be reflected in canCast() and isCasting().
Properties:
Name Type Description type
string 'caststatuschanged' - Source: