2021-06-26 10:18:09 +00:00
sub Main (args as Dynamic) as Void
2021-04-14 07:03:15 +00:00
2019-05-02 17:45:07 +00:00
' If the Rooibos files are included in deployment, run tests
2021-01-31 19:35:18 +00:00
'bs:disable-next-line
2019-05-02 17:45:07 +00:00
if (type(Rooibos__Init) = "Function") then Rooibos__Init()
2019-04-29 16:44:37 +00:00
' The main function that runs when the application is launched.
2019-10-12 20:21:34 +00:00
m.screen = CreateObject("roSGScreen")
2020-07-04 15:10:56 +00:00
2020-08-16 14:44:03 +00:00
' Set global constants
setConstants()
2020-07-04 15:10:56 +00:00
2019-10-12 20:21:34 +00:00
m.port = CreateObject("roMessagePort")
m.screen.setMessagePort(m.port)
2019-10-13 19:33:14 +00:00
m.scene = m.screen.CreateScene("JFScene")
2019-10-12 20:21:34 +00:00
m.screen.show()
2020-04-29 16:26:12 +00:00
' Set any initial Global Variables
2020-05-05 21:09:18 +00:00
m.global = m.screen.getGlobalNode()
m.global.addFields( {app_loaded: false} )
2020-04-29 16:26:12 +00:00
2020-03-08 05:58:39 +00:00
m.overhang = CreateObject("roSGNode", "JFOverhang")
m.scene.insertChild(m.overhang, 0)
2021-02-01 03:10:04 +00:00
2019-04-22 19:08:10 +00:00
app_start:
2020-03-08 05:58:39 +00:00
m.overhang.title = ""
2019-03-05 04:59:31 +00:00
' First thing to do is validate the ability to use the API
2020-03-21 21:22:26 +00:00
if not LoginFlow() then return
wipe_groups()
2019-03-05 04:31:58 +00:00
2020-03-03 23:01:13 +00:00
' load home page
2020-05-05 21:09:18 +00:00
m.overhang.title = tr("Home")
2020-02-26 22:55:47 +00:00
m.overhang.currentUser = m.user.Name
2020-05-04 17:57:40 +00:00
m.overhang.showOptions = true
2020-03-03 23:01:13 +00:00
group = CreateHomeGroup()
2020-12-06 04:59:32 +00:00
group.userConfig = m.user.configuration
2020-12-08 15:56:13 +00:00
group.callFunc("loadLibraries")
2019-10-12 20:21:34 +00:00
m.scene.appendChild(group)
2019-10-13 19:33:14 +00:00
m.scene.observeField("backPressed", m.port)
m.scene.observeField("optionsPressed", m.port)
2020-03-11 03:50:47 +00:00
m.scene.observeField("mutePressed", m.port)
2020-04-29 16:26:12 +00:00
' Handle input messages
input = CreateObject("roInput")
input.SetMessagePort(m.port)
2019-10-13 19:33:14 +00:00
2020-05-07 01:51:17 +00:00
m.device = CreateObject("roDeviceInfo")
m.device.setMessagePort(m.port)
m.device.EnableScreensaverExitedEvent(true)
2020-05-02 16:48:01 +00:00
2021-04-14 07:03:15 +00:00
' Check if we were sent content to play with the startup command (Deep Link)
if (args.mediaType <> invalid) and (args.contentId <> invalid)
video = CreateVideoPlayerGroup(args.contentId)
if video <> invalid then
if group.lastFocus = invalid then group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
group = video
m.scene.appendChild(group)
group.setFocus(true)
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
else
dialog = createObject("roSGNode", "Dialog")
dialog.id = "OKDialog"
dialog.title = tr("Not found")
dialog.message = tr("The requested content does not exist on the server")
dialog.buttons = [tr("OK")]
m.scene.dialog = dialog
m.scene.dialog.observeField("buttonSelected", m.port)
end if
end if
2019-10-13 19:33:14 +00:00
' This is the core logic loop. Mostly for transitioning between scenes
' This now only references m. fields so could be placed anywhere, in theory
' "group" is always "whats on the screen"
' m.scene's children is the "previous view" stack
2021-06-26 10:24:38 +00:00
while true
2019-10-12 20:21:34 +00:00
msg = wait(0, m.port)
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
print "CLOSING SCREEN"
return
2021-04-14 07:03:15 +00:00
2019-10-12 20:21:34 +00:00
else if isNodeEvent(msg, "backPressed")
2020-03-19 03:56:56 +00:00
n = m.scene.getChildCount() - 1
2020-02-17 22:13:20 +00:00
if msg.getRoSGNode().focusedChild <> invalid and msg.getRoSGNode().focusedChild.isSubtype("JFVideo")
2020-02-17 19:30:04 +00:00
stopPlayback()
2020-11-30 07:46:20 +00:00
RemoveCurrentGroup()
2019-10-12 20:21:34 +00:00
else
2020-03-19 03:56:56 +00:00
if n = 1 then return
RemoveCurrentGroup()
2019-10-12 20:21:34 +00:00
end if
2020-03-19 03:56:56 +00:00
group = m.scene.getChild(n-1)
2019-10-13 19:33:14 +00:00
else if isNodeEvent(msg, "optionsPressed")
group.lastFocus = group.focusedChild
panel = group.findNode("options")
panel.visible = true
panel.findNode("panelList").setFocus(true)
else if isNodeEvent(msg, "closeSidePanel")
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
2020-12-08 08:39:58 +00:00
else if isNodeEvent(msg, "quickPlayNode")
reportingNode = msg.getRoSGNode()
itemNode = reportingNode.quickPlayNode
if itemNode = invalid or itemNode.id = "" then return
if itemNode.type = "Episode" or itemNode.type = "Movie" or itemNode.type = "Video" then
video = CreateVideoPlayerGroup(itemNode.id)
if video <> invalid then
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
group = video
m.scene.appendChild(group)
group.setFocus(true)
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
end if
end if
2020-03-12 18:33:45 +00:00
else if isNodeEvent(msg, "selectedItem")
2019-10-12 20:21:34 +00:00
' If you select a library from ANYWHERE, follow this flow
2020-03-14 08:51:40 +00:00
selectedItem = msg.getData()
2021-04-21 19:04:27 +00:00
if selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView" OR selectedItem.type = "Folder" OR selectedItem.type = "Channel" OR selectedItem.type = "Boxset"
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2019-10-12 20:21:34 +00:00
group.setFocus(false)
group.visible = false
2020-10-30 17:23:28 +00:00
m.overhang.title = selectedItem.title
2021-02-12 15:17:55 +00:00
group = CreateItemGrid(selectedItem)
2020-10-30 17:23:28 +00:00
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
2020-03-14 08:51:40 +00:00
else if selectedItem.type = "Episode" then
2020-03-03 23:01:13 +00:00
' play episode
' todo: create an episode page to link here
2020-03-14 08:51:40 +00:00
video_id = selectedItem.id
2020-03-07 19:58:48 +00:00
video = CreateVideoPlayerGroup(video_id)
if video <> invalid then
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2020-03-07 19:58:48 +00:00
group.setFocus(false)
group.visible = false
group = video
m.scene.appendChild(group)
group.setFocus(true)
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
end if
2020-03-14 08:51:40 +00:00
else if selectedItem.type = "Series" then
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2020-03-12 21:20:00 +00:00
group.setFocus(false)
group.visible = false
2020-07-11 13:37:33 +00:00
m.overhang.title = selectedItem.title
2020-03-12 21:20:00 +00:00
m.overhang.showOptions = false
m.scene.unobserveField("optionsPressed")
2020-03-14 08:51:40 +00:00
group = CreateSeriesDetailsGroup(selectedItem.json)
2020-07-11 13:37:33 +00:00
group.overhangTitle = selectedItem.title
2020-03-12 21:20:00 +00:00
m.scene.appendChild(group)
2020-03-14 08:51:40 +00:00
else if selectedItem.type = "Movie" then
2020-03-03 23:01:13 +00:00
' open movie detail page
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2020-03-03 23:01:13 +00:00
group.setFocus(false)
group.visible = false
2020-07-11 13:37:33 +00:00
m.overhang.title = selectedItem.title
2020-03-03 23:01:13 +00:00
m.overhang.showOptions = false
2020-03-08 01:44:02 +00:00
m.scene.unobserveField("optionsPressed")
2020-03-14 08:51:40 +00:00
group = CreateMovieDetailsGroup(selectedItem)
2020-07-11 13:37:33 +00:00
group.overhangTitle = selectedItem.title
2020-03-03 23:01:13 +00:00
m.scene.appendChild(group)
2020-10-27 17:12:18 +00:00
else if selectedItem.type = "TvChannel" or selectedItem.type = "Video" then
2020-10-17 19:07:32 +00:00
' play channel feed
video_id = selectedItem.id
2020-10-25 09:40:41 +00:00
' Show Channel Loading spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Channel Data")
m.scene.dialog = dialog
2020-10-17 19:07:32 +00:00
video = CreateVideoPlayerGroup(video_id)
2020-10-25 09:40:41 +00:00
dialog.close = true
2020-10-17 19:07:32 +00:00
if video <> invalid then
2020-11-23 17:13:57 +00:00
if group.lastFocus = invalid then group.lastFocus = group.focusedChild
2020-10-17 19:07:32 +00:00
group.setFocus(false)
group.visible = false
group = video
m.scene.appendChild(group)
group.setFocus(true)
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
2021-02-01 03:10:04 +00:00
else
2020-10-25 09:40:41 +00:00
dialog = createObject("roSGNode", "Dialog")
2021-03-26 16:12:38 +00:00
dialog.id = "OKDialog"
2020-10-25 09:40:41 +00:00
dialog.title = tr("Error loading Channel Data")
dialog.message = tr("Unable to load Channel Data from the server")
dialog.buttons = [tr("OK")]
m.scene.dialog = dialog
2021-03-07 12:35:32 +00:00
m.scene.dialog.observeField("buttonSelected", m.port)
2020-10-17 19:07:32 +00:00
end if
2019-10-12 20:21:34 +00:00
else
2019-10-13 19:33:14 +00:00
' TODO - switch on more node types
2021-02-12 15:19:30 +00:00
message_dialog("This type is not yet supported: " + selectedItem.type + ".")
2019-10-12 20:21:34 +00:00
end if
else if isNodeEvent(msg, "movieSelected")
' If you select a movie from ANYWHERE, follow this flow
2019-10-12 21:00:07 +00:00
node = getMsgPicker(msg, "picker")
2019-10-12 20:21:34 +00:00
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2019-10-12 20:21:34 +00:00
group.setFocus(false)
group.visible = false
2020-02-29 02:09:56 +00:00
m.overhang.title = node.title
2020-03-01 01:41:57 +00:00
m.overhang.showOptions = false
2020-03-08 01:44:02 +00:00
m.scene.unobserveField("optionsPressed")
2019-10-13 19:33:14 +00:00
group = CreateMovieDetailsGroup(node)
2020-02-29 02:09:56 +00:00
group.overhangTitle = node.title
2019-10-12 20:21:34 +00:00
m.scene.appendChild(group)
2019-12-07 02:49:37 +00:00
else if isNodeEvent(msg, "seriesSelected")
' If you select a TV Series from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker")
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2019-12-07 02:49:37 +00:00
group.setFocus(false)
group.visible = false
2020-02-29 02:09:56 +00:00
m.overhang.title = node.title
2020-03-01 01:41:57 +00:00
m.overhang.showOptions = false
2020-03-08 01:44:02 +00:00
m.scene.unobserveField("optionsPressed")
2019-12-07 02:49:37 +00:00
group = CreateSeriesDetailsGroup(node)
2020-02-29 02:09:56 +00:00
group.overhangTitle = node.title
2019-12-07 02:49:37 +00:00
m.scene.appendChild(group)
else if isNodeEvent(msg, "seasonSelected")
' If you select a TV Season from ANYWHERE, follow this flow
ptr = msg.getData()
' ptr is for [row, col] of selected item... but we only have 1 row
series = msg.getRoSGNode()
node = series.seasonData.items[ptr[1]]
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild.focusedChild
2019-12-07 02:49:37 +00:00
group.setFocus(false)
group.visible = false
2020-02-29 02:09:56 +00:00
m.overhang.title = series.overhangTitle + " - " + node.title
2020-03-01 01:41:57 +00:00
m.overhang.showOptions = false
2020-03-08 01:44:02 +00:00
m.scene.unobserveField("optionsPressed")
2019-12-07 02:49:37 +00:00
group = CreateSeasonDetailsGroup(series.itemContent, node)
m.scene.appendChild(group)
else if isNodeEvent(msg, "episodeSelected")
' If you select a TV Episode from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker")
video_id = node.id
2020-03-04 02:46:26 +00:00
video = CreateVideoPlayerGroup(video_id)
if video <> invalid then
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2020-03-04 02:46:26 +00:00
group.setFocus(false)
group.visible = false
group = video
m.scene.appendChild(group)
group.setFocus(true)
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
end if
2019-10-13 20:52:34 +00:00
else if isNodeEvent(msg, "search_value")
query = msg.getRoSGNode().search_value
group.findNode("SearchBox").visible = false
options = group.findNode("SearchSelect")
options.visible = true
options.setFocus(true)
2021-06-10 03:17:27 +00:00
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Search Data")
m.scene.dialog = dialog
2019-10-13 20:52:34 +00:00
results = SearchMedia(query)
2021-06-10 03:17:27 +00:00
dialog.close = true
2019-10-13 20:52:34 +00:00
options.itemData = results
options.query = query
else if isNodeEvent(msg, "itemSelected")
' Search item selected
node = getMsgPicker(msg)
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2019-10-13 20:52:34 +00:00
group.setFocus(false)
group.visible = false
' TODO - swap this based on target.mediatype
2020-11-16 21:53:39 +00:00
' types: [ Series (Show), Episode, Movie, Audio, Person, Studio, MusicArtist ]
if node.type = "Series" then
group = CreateSeriesDetailsGroup(node)
else
group = CreateMovieDetailsGroup(node)
end if
2019-10-13 20:52:34 +00:00
m.scene.appendChild(group)
m.overhang.title = group.overhangTitle
2019-10-12 21:00:07 +00:00
else if isNodeEvent(msg, "buttonSelected")
' If a button is selected, we have some determining to do
btn = getButton(msg)
2021-04-14 07:03:15 +00:00
if btn <> invalid and btn.id = "play-button"
2020-10-24 16:23:20 +00:00
' Check is a specific Audio Stream was selected
audio_stream_idx = 1
if group.selectedAudioStreamIndex <> invalid
audio_stream_idx = group.selectedAudioStreamIndex
end if
2019-10-13 19:33:14 +00:00
' TODO - Do a better job of picking the last focus
2019-10-14 17:03:48 +00:00
' This is currently page layout Group, button Group, then button
2019-10-12 21:00:07 +00:00
video_id = group.id
2020-10-24 16:23:20 +00:00
video = CreateVideoPlayerGroup(video_id, audio_stream_idx)
2020-03-04 02:46:26 +00:00
if video <> invalid then
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild.focusedChild.focusedChild
2020-03-04 02:46:26 +00:00
group.setFocus(false)
group.visible = false
group = video
m.scene.appendChild(group)
group.setFocus(true)
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
end if
2021-04-14 07:03:15 +00:00
else if btn <> invalid and btn.id = "watched-button"
2019-10-15 01:30:10 +00:00
movie = group.itemContent
if movie.watched
UnmarkItemWatched(movie.id)
else
MarkItemWatched(movie.id)
end if
movie.watched = not movie.watched
2021-04-14 07:03:15 +00:00
else if btn <> invalid and btn.id = "favorite-button"
2019-10-15 01:30:10 +00:00
movie = group.itemContent
if movie.favorite
UnmarkItemFavorite(movie.id)
else
MarkItemFavorite(movie.id)
end if
movie.favorite = not movie.favorite
2021-03-26 16:12:38 +00:00
else
' If there are no other button matches, check if this is a simple "OK" Dialog & Close if so
dialog = msg.getRoSGNode()
if dialog.id = "OKDialog" then
dialog.unobserveField("buttonSelected")
dialog.close = true
end if
2019-10-12 21:00:07 +00:00
end if
2019-10-13 19:33:14 +00:00
else if isNodeEvent(msg, "optionSelected")
button = msg.getRoSGNode()
if button.id = "goto_search"
2019-10-13 20:52:34 +00:00
' Exit out of the side panel
panel.visible = false
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
2020-12-06 22:57:45 +00:00
group.lastFocus = group.focusedChild
2019-10-13 20:52:34 +00:00
group.setFocus(false)
group.visible = false
2020-04-29 23:55:51 +00:00
m.overhang.showOptions = false
m.scene.unobserveField("optionsPressed")
2019-10-13 20:52:34 +00:00
group = CreateSearchPage()
m.scene.appendChild(group)
m.overhang.title = group.overhangTitle
group.findNode("SearchBox").findNode("search-input").setFocus(true)
group.findNode("SearchBox").findNode("search-input").active = true
2019-10-13 19:33:14 +00:00
else if button.id = "change_server"
unset_setting("server")
unset_setting("port")
SignOut()
wipe_groups()
goto app_start
else if button.id = "sign_out"
SignOut()
wipe_groups()
goto app_start
end if
2020-03-28 20:04:57 +00:00
else if isNodeEvent(msg, "selectSubtitlePressed")
node = m.scene.focusedChild
if node.isSubType("JFVideo") then
trackSelected = selectSubtitleTrack(node.Subtitles, node.SelectedSubtitle)
2021-06-12 15:30:32 +00:00
if trackSelected <> invalid and trackSelected <> -2 then
2020-03-28 20:04:57 +00:00
changeSubtitleDuringPlayback(trackSelected)
end if
end if
2020-02-17 19:30:04 +00:00
else if isNodeEvent(msg, "fire")
ReportPlayback(group, "update")
else if isNodeEvent(msg, "state")
node = msg.getRoSGNode()
if node.state = "finished" then
2020-03-19 03:56:56 +00:00
stopPlayback()
2020-11-30 07:46:20 +00:00
if node.showID = invalid then
RemoveCurrentGroup()
else
2021-03-07 15:53:40 +00:00
nextEpisode =autoPlayNextEpisode(node.id, node.showID)
if nextEpisode <> invalid then group = nextEpisode
2020-11-30 07:46:20 +00:00
end if
2020-02-17 19:30:04 +00:00
else if node.state = "playing" or node.state = "paused" then
ReportPlayback(group, "update")
end if
2020-03-11 03:50:47 +00:00
else if type(msg) = "roDeviceInfoEvent" then
event = msg.GetInfo()
2021-06-12 14:23:50 +00:00
if event.exitedScreensaver = true then
2020-05-02 16:48:01 +00:00
m.overhang.callFunc("resetTime")
if group.subtype() = "Home" then
currentTime = CreateObject("roDateTime").AsSeconds()
group.timeLastRefresh = currentTime
group.callFunc("refresh")
end if
' todo: add other screens to be refreshed - movie detail, tv series, episode list etc.
2020-03-11 03:50:47 +00:00
else
print "Unhandled roDeviceInfoEvent:"
print msg.GetInfo()
end if
2021-04-14 07:03:15 +00:00
else if type(msg) = "roInputEvent"
if msg.IsInput()
info = msg.GetInfo()
if info.DoesExist("mediatype") and info.DoesExist("contentid")
video = CreateVideoPlayerGroup(info.contentId)
if video <> invalid then
if group.lastFocus = invalid then group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
group = video
m.scene.appendChild(group)
group.setFocus(true)
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
else
dialog = createObject("roSGNode", "Dialog")
dialog.id = "OKDialog"
dialog.title = tr("Not found")
dialog.message = tr("The requested content does not exist on the server")
dialog.buttons = [tr("OK")]
m.scene.dialog = dialog
m.scene.dialog.observeField("buttonSelected", m.port)
end if
end if
end if
2019-10-12 20:21:34 +00:00
else
2020-11-23 17:13:57 +00:00
print "Unhandled " type(msg)
2019-10-12 20:21:34 +00:00
print msg
end if
end while
2019-04-22 19:08:10 +00:00
2021-06-26 10:18:09 +00:00
end sub
2019-04-22 19:08:10 +00:00
2020-03-22 22:40:47 +00:00
function LoginFlow(startOver = false as boolean)
2020-03-22 15:20:21 +00:00
if m.scene <> invalid then
m.scene.unobserveField("backPressed")
end if
2019-04-29 16:44:37 +00:00
'Collect Jellyfin server and user information
2019-03-06 02:28:52 +00:00
start_login:
2021-04-04 13:41:44 +00:00
if get_setting("server") = invalid then startOver = true
if not startOver then
' Show Connecting to Server spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Connecting to Server")
m.scene.dialog = dialog
serverInfoResult = ServerInfo()
dialog.close = true
end if
2021-04-04 13:46:42 +00:00
if startOver or serverInfoResult.Error then
2019-03-05 04:31:58 +00:00
print "Get server details"
2020-04-29 16:26:12 +00:00
SendPerformanceBeacon("AppDialogInitiate") ' Roku Performance monitoring - Dialog Starting
2020-03-22 22:40:47 +00:00
serverSelection = CreateServerGroup()
2020-04-29 16:26:12 +00:00
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
2020-03-22 22:40:47 +00:00
if serverSelection = "backPressed" then
2020-03-21 21:22:26 +00:00
print "backPressed"
wipe_groups()
return false
end if
2019-03-05 04:31:58 +00:00
end if
2019-01-30 04:19:27 +00:00
2019-03-05 04:31:58 +00:00
if get_setting("active_user") = invalid then
2020-04-29 16:26:12 +00:00
SendPerformanceBeacon("AppDialogInitiate") ' Roku Performance monitoring - Dialog Starting
2020-03-22 22:40:47 +00:00
publicUsers = GetPublicUsers()
if publicUsers.count() then
publicUsersNodes = []
for each item in publicUsers
2020-03-21 21:22:26 +00:00
user = CreateObject("roSGNode", "PublicUserData")
user.id = item.Id
2020-03-22 22:40:47 +00:00
user.name = item.Name
2020-03-21 21:22:26 +00:00
if item.PrimaryImageTag <> invalid then
user.ImageURL = UserImageURL(user.id, { "tag": item.PrimaryImageTag })
end if
2020-03-22 22:40:47 +00:00
publicUsersNodes.push(user)
2020-03-21 21:22:26 +00:00
end for
2020-03-23 19:10:57 +00:00
userSelected = CreateUserSelectGroup(publicUsersNodes)
2020-03-21 21:22:26 +00:00
m.scene.focusedChild.visible = false
2020-03-23 19:59:01 +00:00
if userSelected = "backPressed" then
2020-04-29 16:26:12 +00:00
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
2020-03-22 15:20:21 +00:00
return LoginFlow(true)
2020-03-21 21:22:26 +00:00
else
'Try to login without password. If the token is valid, we're done
2020-03-23 19:59:01 +00:00
get_token(userSelected, "")
2020-03-21 21:22:26 +00:00
if get_setting("active_user") <> invalid then
m.user = AboutMe()
2020-11-29 11:18:23 +00:00
LoadUserPreferences()
2020-04-29 16:26:12 +00:00
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
2020-03-21 21:22:26 +00:00
return true
end if
end if
2020-05-05 21:09:18 +00:00
else
2020-03-23 19:10:57 +00:00
userSelected = ""
2020-03-21 21:22:26 +00:00
end if
2020-03-23 19:10:57 +00:00
passwordEntry = CreateSigninGroup(userSelected)
2020-04-29 16:26:12 +00:00
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
2020-03-22 22:40:47 +00:00
if passwordEntry = "backPressed" then
2020-03-21 21:22:26 +00:00
m.scene.focusedChild.visible = false
2020-03-22 15:20:21 +00:00
return LoginFlow(true)
2020-03-21 21:22:26 +00:00
end if
2019-03-05 04:31:58 +00:00
end if
2019-03-02 22:03:11 +00:00
2019-03-05 04:59:31 +00:00
m.user = AboutMe()
2019-04-20 17:40:06 +00:00
if m.user = invalid or m.user.id <> get_setting("active_user")
2019-03-06 02:28:52 +00:00
print "Login failed, restart flow"
2019-04-20 17:40:06 +00:00
unset_setting("active_user")
2019-03-06 02:28:52 +00:00
goto start_login
2019-03-05 04:59:31 +00:00
end if
2019-10-13 19:33:14 +00:00
2020-11-29 11:18:23 +00:00
LoadUserPreferences()
2019-10-13 19:33:14 +00:00
wipe_groups()
2020-05-31 10:57:41 +00:00
'Send Device Profile information to server
body = getDeviceCapabilities()
req = APIRequest("/Sessions/Capabilities/Full")
req.SetRequest("POST")
postJson(req, FormatJson(body))
2020-03-21 21:22:26 +00:00
return true
end function
2019-10-05 07:50:05 +00:00
sub RunScreenSaver()
print "Starting screensaver..."
screen = createObject("roSGScreen")
m.port = createObject("roMessagePort")
screen.setMessagePort(m.port)
2021-06-26 10:04:32 +00:00
screen.createScene("Screensaver")
2019-10-05 07:50:05 +00:00
screen.Show()
2021-06-26 10:24:38 +00:00
while true
2019-10-05 07:50:05 +00:00
msg = wait(8000, m.port)
2021-06-26 10:24:38 +00:00
if msg <> invalid
2019-10-05 07:50:05 +00:00
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
end if
end while
2019-10-13 19:33:14 +00:00
end sub
sub wipe_groups()
' The 1 remaining child should be the overhang
2021-06-26 10:24:38 +00:00
while m.scene.getChildCount() > 1
2019-10-13 19:33:14 +00:00
m.scene.removeChildIndex(1)
end while
2020-02-15 17:56:56 +00:00
end sub
2020-03-19 03:56:56 +00:00
sub RemoveCurrentGroup()
' Pop a group off the stack and expose what's below
n = m.scene.getChildCount() - 1
group = m.scene.focusedChild
m.scene.removeChildIndex(n)
prevOptionsAvailable = group.optionsAvailable
group = m.scene.getChild(n - 1)
m.overhang.title = group.overhangTitle
m.overhang.showOptions = group.optionsAvailable
if group.optionsAvailable <> prevOptionsAvailable then
if group.optionsAvailable = false then
m.scene.unobserveField("optionsPressed")
else
m.scene.observeField("optionsPressed", m.port)
end if
end if
m.overhang.visible = true
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
2020-03-25 02:47:26 +00:00
if group.subtype() = "Home" then
2020-03-25 04:20:37 +00:00
currentTime = CreateObject("roDateTime").AsSeconds()
if group.timeLastRefresh = invalid or (currentTime - group.timeLastRefresh) > 20 then
group.timeLastRefresh = currentTime
group.callFunc("refresh")
end if
2020-03-24 00:45:40 +00:00
end if
2020-03-19 03:56:56 +00:00
group.visible = true
end sub
2020-04-29 16:26:12 +00:00
2020-05-05 21:09:18 +00:00
' Roku Performance monitoring
2020-04-29 16:26:12 +00:00
sub SendPerformanceBeacon(signalName as string)
2020-05-05 21:09:18 +00:00
if m.global.app_loaded = false then
m.scene.signalBeacon(signalName)
2020-04-29 16:26:12 +00:00
end if
2021-04-14 07:03:15 +00:00
end sub