AI-generated Key Takeaways
-
RemotePlayerController manages a player object, updates its properties, and provides events for player changes to bind remote player data to the cast state.
-
The constructor requires a non-null RemotePlayer object to control.
-
Methods allow for adding/removing event listeners for player changes, formatting time, calculating seek position/time, controlling playback (mute/unmute, play/pause, seek, stop, skip ad), and setting volume.
cast.
framework
.
RemotePlayerController
Cast remote player controller, which provides data binding for a remote player to the cast state. It manages a player object and updates its properties, providing events for player changes.
Constructor
RemotePlayerController
new RemotePlayerController(player)
Parameter
player
Methods
addEventListener
addEventListener(type, handler)
Registers an event handler for a player change.
Parameter
type
handler
function(non-null cast.framework.RemotePlayerChangedEvent )
Event handler.
getFormattedTime
getFormattedTime(timeInSec)
Converts a number representing an interval of seconds to a string with HH:MM:SS format.
Parameter
timeInSec
number
Must be positive. Intervals longer than 100 hours get truncated silently.
getSeekPosition
getSeekPosition(currentTime, duration) returns number
Convert current play time to a progress percentage.
Parameter
currentTime
number
The current playing time.
duration
number
Current media total playing time.
- Returns
-
numberCurrent seek position in percentage.
getSeekTime
getSeekTime(currentPosition, duration) returns number
Convert current play seek percentage to seek time.
Parameter
currentPosition
number
Current seek position in percentage.
duration
number
Current media total playing time.
- Returns
-
numberThe current playing time.
muteOrUnmute
muteOrUnmute()
Mute or unmute the audio of the connected device.
playOrPause
playOrPause()
Play or pause current playing media.
removeEventListener
removeEventListener(type, handler)
Unregister an event handler for a player change.
Parameter
type
handler
function(non-null cast.framework.RemotePlayerChangedEvent )
Event handler.
seek
seek()
Seeks the media item to player currentTime value.
setVolumeLevel
setVolumeLevel()
Sets the volume level of the connected device to the player volumeLevel value.
skipAd
skipAd()
Skip the ad currently playing on the receiver.
stop
stop()
Stops the media player.

