* Dial+Lounge API PoC * format * Fix for chrome * comments * Rate limit and logger stuff * rename route * remove invalid routes * remove device image * Simplify device description * command test * Lint fix * register pairing code * tv code UI * Lint fix * Avoid creating lots of objects * dpad command * small refactor * tweak * validation * timer * fix * Revert "timer" This reverts commit e349565910882408898c9bddda55dadaa9d743de. * Commands * setVolume command * lounge service timer * Some state messages * Lint fix * player state sync * voice handler * Adjustments, and add a TODO list * Lint fix * comment * play at timestamp * Remote screen UI * UI adjustment * Small refactor * Refactor long polling * Add TODO * Manage logging a bit better to avoid spam in DIAL server * cache dial file * logging * comment * Join lounge lazily * long poller tweak * ui tweak * set shouldQuit field * remote connect notification * Lint fix * Randomize device id, new device on start * Lint fix * Lounge disconnect on start * Speed up lounge by not blocking on sent messages * add version to lounge data saved * dial server fix rendezvous * todo * no message * Display network name * playlist changes * Lint fix * tweak params * tweak * player state * comments * Refactor Video Queue (#295) * Refactor Video Queue * Video queue and playlists * Web app casting * queue playlist notification * VideoQueueView work * restore properties * changes * queue notification and previous/next state * Lint fix * very basic error handling * Update changelog and privacy policy --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
127 lines
4.1 KiB
Plaintext
127 lines
4.1 KiB
Plaintext
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
|
import "pkg:/source/utils/StringUtils.bs"
|
|
import "pkg:/source/utils/Types.bs"
|
|
|
|
namespace LoungeMessages
|
|
|
|
function OnHasPreviousNextChanged(hasPrevious as boolean, hasNext as boolean) as object
|
|
message = {
|
|
commandType: COMMAND_ON_PREVIOUS_NEXT_CHANGE
|
|
}
|
|
commandArgs = {}
|
|
commandArgs[FIELD_HAS_PREVIOUS] = hasPrevious
|
|
commandArgs[FIELD_HAS_NEXT] = hasNext
|
|
message.commandArgs = commandArgs
|
|
return message
|
|
end function
|
|
|
|
function OnStateChange(player as object, overrides = invalid as object) as object
|
|
message = {
|
|
commandType: COMMAND_ON_STATE_CHANGE
|
|
}
|
|
|
|
commandArgs = {}
|
|
|
|
if player = invalid
|
|
commandArgs[FIELD_STATE] = PlayerState.UNSTARTED
|
|
message.commandArgs = commandArgs
|
|
return message
|
|
end if
|
|
|
|
commandArgs[FIELD_STATE] = GetPlayerState(player)
|
|
commandArgs[FIELD_CURRENT_TIME] = ValidDouble(player.position)
|
|
commandArgs[FIELD_SEEKABLE_START_TIME] = 0
|
|
|
|
content = player.content
|
|
if content <> invalid
|
|
metadata = content.metadata
|
|
if metadata <> invalid
|
|
lengthSeconds = metadata.lengthSeconds
|
|
if IsInt(lengthSeconds)
|
|
commandArgs[FIELD_DURATION] = lengthSeconds
|
|
commandArgs[FIELD_SEEKABLE_END_TIME] = lengthSeconds
|
|
|
|
if commandArgs[FIELD_STATE] = PlayerState.PLAYING or commandArgs[FIELD_STATE] = PlayerState.PAUSED or commandArgs[FIELD_STATE] = PlayerState.BUFFERING
|
|
commandArgs[FIELD_LOADED_TIME] = lengthSeconds
|
|
end if
|
|
end if
|
|
end if
|
|
end if
|
|
|
|
if overrides <> invalid
|
|
commandArgs.Append(overrides)
|
|
end if
|
|
|
|
message.commandArgs = commandArgs
|
|
|
|
return message
|
|
end function
|
|
|
|
function NowPlaying(player as object, overrides = invalid as object) as object
|
|
message = {
|
|
commandType: COMMAND_NOW_PLAYING
|
|
}
|
|
|
|
if player = invalid
|
|
return message
|
|
end if
|
|
|
|
commandArgs = {}
|
|
|
|
commandArgs[FIELD_CURRENT_TIME] = ValidDouble(player.position)
|
|
commandArgs[FIELD_SEEKABLE_START_TIME] = 0
|
|
commandArgs[FIELD_CURRENT_INDEX] = 0
|
|
|
|
commandArgs[FIELD_STATE] = GetPlayerState(player)
|
|
|
|
content = player.content
|
|
if content <> invalid
|
|
metadata = content.metadata
|
|
if metadata <> invalid
|
|
lengthSeconds = metadata.lengthSeconds
|
|
if IsInt(lengthSeconds)
|
|
commandArgs[FIELD_DURATION] = lengthSeconds
|
|
commandArgs[FIELD_SEEKABLE_END_TIME] = lengthSeconds
|
|
|
|
if commandArgs[FIELD_STATE] = PlayerState.PLAYING or commandArgs[FIELD_STATE] = PlayerState.PAUSED or commandArgs[FIELD_STATE] = PlayerState.BUFFERING
|
|
commandArgs[FIELD_LOADED_TIME] = lengthSeconds
|
|
end if
|
|
end if
|
|
videoId = metadata.videoId
|
|
if not StringUtils.IsNullOrEmpty(videoId)
|
|
commandArgs[FIELD_VIDEO_ID] = videoId
|
|
end if
|
|
end if
|
|
end if
|
|
|
|
if overrides <> invalid
|
|
commandArgs.Append(overrides)
|
|
end if
|
|
|
|
message.commandArgs = commandArgs
|
|
return message
|
|
end function
|
|
|
|
function GetPlayerState(player as object) as PlayerState
|
|
if player = invalid
|
|
return PlayerState.UNSTARTED
|
|
end if
|
|
|
|
state = player.state
|
|
if state = "playing"
|
|
return PlayerState.PLAYING
|
|
else if state = "paused"
|
|
return PlayerState.PAUSED
|
|
else if state = "buffering"
|
|
return PlayerState.BUFFERING
|
|
else if state = "finished"
|
|
return PlayerState.ENDED
|
|
else if state = "stopped" or state = "stopping"
|
|
return PlayerState.STOPPED
|
|
end if
|
|
|
|
return PlayerState.UNSTARTED
|
|
end function
|
|
|
|
end namespace
|