2021-07-09 20:08:32 +00:00
sub Main (args as dynamic) as void
2020-10-25 09:40:41 +00:00
2021-07-09 20:08:32 +00:00
' If the Rooibos files are included in deployment, run tests
'bs:disable-next-line
if type(Rooibos__Init) = "Function" then Rooibos__Init()
2020-10-25 09:40:41 +00:00
2021-07-09 20:08:32 +00:00
' The main function that runs when the application is launched.
m.screen = CreateObject("roSGScreen")
' Set global constants
setConstants()
2022-06-03 01:29:07 +00:00
' Write screen tracker for screensaver
WriteAsciiFile("tmp:/scene.temp", "")
MoveFile("tmp:/scene.temp", "tmp:/scene")
2022-05-01 10:53:39 +00:00
' Temporary code to migrate MPEG2 setting from device setting to user setting
' Added for 1.4.13 release and should probably be removed for 1.4.15
if get_setting("playback.mpeg2") <> invalid and registry_read("playback.mpeg2", get_setting("active_user")) = invalid
set_user_setting("playback.mpeg2", get_setting("playback.mpeg2"))
end if
' End Temporary code
2021-07-09 20:08:32 +00:00
m.port = CreateObject("roMessagePort")
m.screen.setMessagePort(m.port)
m.scene = m.screen.CreateScene("JFScene")
m.screen.show()
' Set any initial Global Variables
m.global = m.screen.getGlobalNode()
2021-09-01 00:39:35 +00:00
playstateTask = CreateObject("roSGNode", "PlaystateTask")
playstateTask.id = "playstateTask"
2021-10-10 01:51:33 +00:00
sceneManager = CreateObject("roSGNode", "SceneManager")
2021-07-09 20:08:32 +00:00
2021-10-10 01:51:33 +00:00
m.global.addFields({ app_loaded: false, playstateTask: playstateTask, sceneManager: sceneManager })
2021-07-09 20:08:32 +00:00
app_start:
' First thing to do is validate the ability to use the API
if not LoginFlow() then return
2021-10-10 02:04:37 +00:00
sceneManager.callFunc("clearScenes")
2021-07-09 20:08:32 +00:00
' load home page
2021-10-10 01:51:33 +00:00
sceneManager.currentUser = m.user.Name
2021-07-09 20:08:32 +00:00
group = CreateHomeGroup()
group.userConfig = m.user.configuration
group.callFunc("loadLibraries")
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", group)
2021-07-09 20:08:32 +00:00
2021-09-14 02:03:32 +00:00
m.scene.observeField("exit", m.port)
2021-07-09 20:08:32 +00:00
' Handle input messages
input = CreateObject("roInput")
input.SetMessagePort(m.port)
m.device = CreateObject("roDeviceInfo")
m.device.setMessagePort(m.port)
m.device.EnableScreensaverExitedEvent(true)
2021-09-14 02:03:32 +00:00
m.device.EnableAppFocusEvent(false)
2021-07-09 20:08:32 +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)
2020-10-24 16:23:20 +00:00
2022-07-09 08:28:15 +00:00
if video <> invalid and video.errorMsg <> "introaborted"
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", video)
2020-11-30 07:46:20 +00:00
else
2021-07-09 20:08:32 +00:00
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)
2020-11-30 07:46:20 +00:00
end if
2021-07-09 20:08:32 +00:00
end if
' 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
while true
msg = wait(0, m.port)
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
print "CLOSING SCREEN"
return
2021-09-14 02:03:32 +00:00
else if isNodeEvent(msg, "exit")
return
2021-07-09 20:08:32 +00:00
else if isNodeEvent(msg, "closeSidePanel")
2021-10-10 01:51:33 +00:00
group = sceneManager.callFunc("getActiveScene")
2021-07-09 20:08:32 +00:00
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
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"
2022-04-30 13:02:03 +00:00
if itemNode.type = "Episode" and itemNode.selectedAudioStreamIndex <> invalid and itemNode.selectedAudioStreamIndex > 1
2022-04-24 03:49:42 +00:00
video = CreateVideoPlayerGroup(itemNode.id, invalid, itemNode.selectedAudioStreamIndex)
else
video = CreateVideoPlayerGroup(itemNode.id)
end if
2022-07-09 08:28:15 +00:00
if video <> invalid and video.errorMsg <> "introaborted"
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", video)
2021-07-09 20:08:32 +00:00
end if
end if
else if isNodeEvent(msg, "selectedItem")
' If you select a library from ANYWHERE, follow this flow
selectedItem = msg.getData()
if selectedItem.type = "CollectionFolder" or selectedItem.type = "UserView" or selectedItem.type = "Folder" or selectedItem.type = "Channel" or selectedItem.type = "Boxset"
group = CreateItemGrid(selectedItem)
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", group)
2021-07-09 20:08:32 +00:00
else if selectedItem.type = "Episode"
' play episode
' todo: create an episode page to link here
video_id = selectedItem.id
2022-04-30 13:02:03 +00:00
if selectedItem.selectedAudioStreamIndex <> invalid and selectedItem.selectedAudioStreamIndex > 1
2022-04-24 03:49:42 +00:00
video = CreateVideoPlayerGroup(video_id, invalid, selectedItem.selectedAudioStreamIndex)
else
video = CreateVideoPlayerGroup(video_id)
end if
2022-07-09 08:28:15 +00:00
if video <> invalid and video.errorMsg <> "introaborted"
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", video)
2021-07-09 20:08:32 +00:00
end if
else if selectedItem.type = "Series"
group = CreateSeriesDetailsGroup(selectedItem.json)
else if selectedItem.type = "Movie"
' open movie detail page
group = CreateMovieDetailsGroup(selectedItem)
2022-03-13 08:46:03 +00:00
else if selectedItem.type = "Person"
CreatePersonView(selectedItem)
2021-12-18 06:03:33 +00:00
else if selectedItem.type = "TvChannel" or selectedItem.type = "Video" or selectedItem.type = "Program"
2021-07-09 20:08:32 +00:00
' play channel feed
video_id = selectedItem.id
' Show Channel Loading spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Channel Data")
m.scene.dialog = dialog
video = CreateVideoPlayerGroup(video_id)
dialog.close = true
2022-07-09 08:28:15 +00:00
if video <> invalid and video.errorMsg <> "introaborted"
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", video)
2021-07-09 20:08:32 +00:00
else
dialog = createObject("roSGNode", "Dialog")
dialog.id = "OKDialog"
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
m.scene.dialog.observeField("buttonSelected", m.port)
end if
2022-02-06 15:37:02 +00:00
else if selectedItem.type = "Photo"
2022-02-06 22:37:40 +00:00
' Nothing to do here, handled in ItemGrid
2022-05-14 02:35:50 +00:00
else if selectedItem.type = "MusicArtist"
2022-07-19 00:42:22 +00:00
group = CreateArtistView(selectedItem.json)
2022-05-14 21:49:39 +00:00
else if selectedItem.type = "MusicAlbum"
2022-07-19 00:42:22 +00:00
group = CreateAlbumView(selectedItem.json)
2022-05-15 02:30:29 +00:00
else if selectedItem.type = "Audio"
2022-05-29 18:41:06 +00:00
group = CreateAudioPlayerGroup([selectedItem.json])
2021-07-09 20:08:32 +00:00
else
' TODO - switch on more node types
2022-07-12 23:15:59 +00:00
message_dialog("This type is not yet supported: " + selectedItem.type + ".")
2021-07-09 20:08:32 +00:00
end if
else if isNodeEvent(msg, "movieSelected")
' If you select a movie from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker")
group = CreateMovieDetailsGroup(node)
else if isNodeEvent(msg, "seriesSelected")
' If you select a TV Series from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker")
group = CreateSeriesDetailsGroup(node)
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]]
group = CreateSeasonDetailsGroup(series.itemContent, node)
2022-05-14 03:46:05 +00:00
else if isNodeEvent(msg, "musicAlbumSelected")
' If you select a Music Album from ANYWHERE, follow this flow
ptr = msg.getData()
albums = msg.getRoSGNode()
2022-07-19 02:28:06 +00:00
node = albums.musicArtistAlbumData.items[ptr]
2022-07-19 00:42:22 +00:00
group = CreateAlbumView(node)
2022-05-21 20:45:01 +00:00
else if isNodeEvent(msg, "playSong")
' User has selected audio they want us to play
2022-05-15 02:30:29 +00:00
selectedIndex = msg.getData()
2022-05-21 20:45:01 +00:00
screenContent = msg.getRoSGNode()
2022-05-29 18:41:06 +00:00
group = CreateAudioPlayerGroup([screenContent.albumData.items[selectedIndex]])
2022-05-15 19:10:21 +00:00
else if isNodeEvent(msg, "playAllSelected")
2022-05-21 20:45:01 +00:00
' User has selected playlist of of audio they want us to play
screenContent = msg.getRoSGNode()
2022-05-22 21:32:03 +00:00
m.spinner = screenContent.findNode("spinner")
m.spinner.visible = true
2022-05-21 20:45:01 +00:00
group = CreateAudioPlayerGroup(screenContent.albumData.items)
2022-07-19 02:28:06 +00:00
else if isNodeEvent(msg, "playArtistSelected")
' User has selected playlist of of audio they want us to play
screenContent = msg.getRoSGNode()
group = CreateArtistMixGroup(screenContent.pageContent.id)
2022-06-08 13:08:05 +00:00
else if isNodeEvent(msg, "instantMixSelected")
' User has selected instant mix
' User has selected playlist of of audio they want us to play
screenContent = msg.getRoSGNode()
m.spinner = screenContent.findNode("spinner")
2022-07-19 02:28:06 +00:00
if isValid(m.spinner)
m.spinner.visible = true
end if
if isValid(screenContent.albumData)
group = CreateInstantMixGroup(screenContent.albumData.items)
else if isValid(screenContent.pageContent)
group = CreateInstantMixGroup([{ id: screenContent.musicArtistAlbumData.items[0].json.id }])
end if
2021-07-09 20:08:32 +00:00
else if isNodeEvent(msg, "episodeSelected")
' If you select a TV Episode from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker")
video_id = node.id
2022-04-30 13:02:03 +00:00
if node.selectedAudioStreamIndex <> invalid and node.selectedAudioStreamIndex > 1
2022-04-24 03:49:42 +00:00
video = CreateVideoPlayerGroup(video_id, invalid, node.selectedAudioStreamIndex)
else
video = CreateVideoPlayerGroup(video_id)
end if
2022-07-09 08:28:15 +00:00
if video <> invalid and video.errorMsg <> "introaborted"
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", video)
2021-07-09 20:08:32 +00:00
end if
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)
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Search Data")
m.scene.dialog = dialog
results = SearchMedia(query)
dialog.close = true
options.itemData = results
options.query = query
else if isNodeEvent(msg, "itemSelected")
' Search item selected
node = getMsgPicker(msg)
' TODO - swap this based on target.mediatype
' types: [ Series (Show), Episode, Movie, Audio, Person, Studio, MusicArtist ]
if node.type = "Series"
group = CreateSeriesDetailsGroup(node)
2021-07-09 10:53:16 +00:00
else
2021-07-09 20:08:32 +00:00
group = CreateMovieDetailsGroup(node)
2021-04-14 07:03:15 +00:00
end if
2021-07-09 20:08:32 +00:00
else if isNodeEvent(msg, "buttonSelected")
' If a button is selected, we have some determining to do
btn = getButton(msg)
2021-10-10 01:51:33 +00:00
group = sceneManager.callFunc("getActiveScene")
2021-07-09 20:08:32 +00:00
if btn <> invalid and btn.id = "play-button"
2022-03-13 00:36:11 +00:00
' Check if a specific Audio Stream was selected
2021-07-09 20:08:32 +00:00
audio_stream_idx = 1
if group.selectedAudioStreamIndex <> invalid
audio_stream_idx = group.selectedAudioStreamIndex
end if
2022-03-13 00:36:11 +00:00
' Check to see if a specific video "version" was selected
2022-03-13 14:22:55 +00:00
mediaSourceId = invalid
2022-03-13 00:36:11 +00:00
if group.selectedVideoStreamId <> invalid
2022-03-13 14:22:55 +00:00
mediaSourceId = group.selectedVideoStreamId
2022-03-13 00:36:11 +00:00
end if
2022-03-13 14:22:55 +00:00
video_id = group.id
2022-03-13 00:36:11 +00:00
2022-03-13 14:22:55 +00:00
video = CreateVideoPlayerGroup(video_id, mediaSourceId, audio_stream_idx)
2022-07-09 08:28:15 +00:00
if video <> invalid and video.errorMsg <> "introaborted"
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", video)
2021-07-09 20:08:32 +00:00
end if
2022-05-10 07:04:23 +00:00
2022-09-03 07:31:15 +00:00
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
end if
else if btn <> invalid and btn.id = "trailer-button"
audio_stream_idx = 1
mediaSourceId = invalid
video_id = group.id
trailerData = api_API().users.getlocaltrailers(get_setting("active_user"), group.id)
video_id = trailerData[0].id
video = CreateVideoPlayerGroup(video_id, mediaSourceId, audio_stream_idx)
if video <> invalid and video.errorMsg <> "introaborted"
sceneManager.callFunc("pushScene", video)
end if
2022-05-10 07:04:23 +00:00
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
end if
2021-07-09 20:08:32 +00:00
else if btn <> invalid and btn.id = "watched-button"
movie = group.itemContent
if movie.watched
UnmarkItemWatched(movie.id)
else
MarkItemWatched(movie.id)
end if
movie.watched = not movie.watched
else if btn <> invalid and btn.id = "favorite-button"
movie = group.itemContent
if movie.favorite
UnmarkItemFavorite(movie.id)
else
MarkItemFavorite(movie.id)
end if
movie.favorite = not movie.favorite
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"
dialog.unobserveField("buttonSelected")
dialog.close = true
end if
end if
else if isNodeEvent(msg, "optionSelected")
button = msg.getRoSGNode()
2021-10-10 01:51:33 +00:00
group = sceneManager.callFunc("getActiveScene")
2021-07-09 20:08:32 +00:00
if button.id = "goto_search"
' Exit out of the side panel
2021-10-09 19:02:34 +00:00
panel = group.findNode("options")
2021-07-09 20:08:32 +00:00
panel.visible = false
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
group = CreateSearchPage()
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", group)
2021-07-09 20:08:32 +00:00
group.findNode("SearchBox").findNode("search-input").setFocus(true)
group.findNode("SearchBox").findNode("search-input").active = true
else if button.id = "change_server"
unset_setting("server")
unset_setting("port")
2021-12-30 01:00:13 +00:00
SignOut(false)
2021-10-10 02:04:37 +00:00
sceneManager.callFunc("clearScenes")
2021-07-09 20:08:32 +00:00
goto app_start
else if button.id = "sign_out"
SignOut()
2021-10-10 02:04:37 +00:00
sceneManager.callFunc("clearScenes")
2021-07-09 20:08:32 +00:00
goto app_start
2022-05-01 10:51:28 +00:00
else if button.id = "settings"
' Exit out of the side panel
panel = group.findNode("options")
panel.visible = false
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
sceneManager.callFunc("settings")
2021-07-09 20:08:32 +00:00
end if
else if isNodeEvent(msg, "selectSubtitlePressed")
node = m.scene.focusedChild
2021-12-23 07:56:57 +00:00
if node.focusedChild <> invalid and node.focusedChild.isSubType("JFVideo")
2021-07-09 20:08:32 +00:00
trackSelected = selectSubtitleTrack(node.Subtitles, node.SelectedSubtitle)
if trackSelected <> invalid and trackSelected <> -2
changeSubtitleDuringPlayback(trackSelected)
end if
end if
else if isNodeEvent(msg, "state")
node = msg.getRoSGNode()
if node.state = "finished"
2021-09-14 02:03:32 +00:00
node.control = "stop"
2022-07-04 09:09:16 +00:00
2022-07-04 09:33:51 +00:00
' If node allows retrying using Transcode Url, give that shot
2022-07-27 12:00:13 +00:00
if isValid(node.retryWithTranscoding) and node.retryWithTranscoding
2022-07-13 07:08:06 +00:00
retryVideo = CreateVideoPlayerGroup(node.Id, invalid, node.audioIndex, true, false)
2022-07-04 09:09:16 +00:00
m.global.sceneManager.callFunc("popScene")
if retryVideo <> invalid
m.global.sceneManager.callFunc("pushScene", retryVideo)
2022-07-04 09:33:51 +00:00
end if
2022-07-04 09:09:16 +00:00
else if node.showID = invalid
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("popScene")
2021-07-09 20:08:32 +00:00
else
2021-09-14 02:03:32 +00:00
autoPlayNextEpisode(node.id, node.showID)
2021-07-09 20:08:32 +00:00
end if
end if
2022-03-13 08:46:03 +00:00
'else if isNodeEvent(msg, "selectedExtra")
'rl = msg.getData()
'sel = rl.rowItemSelected
'? "msg.getfield():" + msg.getField()
'stop
'CreatePersonView(msg.getData())
2021-07-09 20:08:32 +00:00
else if type(msg) = "roDeviceInfoEvent"
event = msg.GetInfo()
2021-10-10 01:51:33 +00:00
group = sceneManager.callFunc("getActiveScene")
2021-07-09 20:08:32 +00:00
if event.exitedScreensaver = true
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("resetTime")
2021-07-09 20:08:32 +00:00
if group.subtype() = "Home"
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.
else
print "Unhandled roDeviceInfoEvent:"
print msg.GetInfo()
end if
else if type(msg) = "roInputEvent"
if msg.IsInput()
info = msg.GetInfo()
if info.DoesExist("mediatype") and info.DoesExist("contentid")
video = CreateVideoPlayerGroup(info.contentId)
2022-07-09 08:28:15 +00:00
if video <> invalid and video.errorMsg <> "introaborted"
2021-10-10 01:51:33 +00:00
sceneManager.callFunc("pushScene", video)
2021-07-09 20:08:32 +00:00
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
else
print "Unhandled " type(msg)
print msg
end if
end while
2019-04-22 19:08:10 +00:00
end sub
2020-03-22 22:40:47 +00:00
function LoginFlow(startOver = false as boolean)
2021-07-09 20:08:32 +00:00
'Collect Jellyfin server and user information
start_login:
2021-04-04 13:41:44 +00:00
2021-07-09 20:08:32 +00:00
if get_setting("server") = invalid then startOver = true
2021-04-04 13:41:44 +00:00
2021-07-09 20:08:32 +00:00
invalidServer = true
if not startOver
2021-04-04 13:41:44 +00:00
' Show Connecting to Server spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Connecting to Server")
m.scene.dialog = dialog
2021-06-26 13:38:52 +00:00
invalidServer = ServerInfo().Error
2021-04-04 13:41:44 +00:00
dialog.close = true
2020-03-21 21:22:26 +00:00
end if
2021-07-09 20:08:32 +00:00
2021-12-26 18:52:43 +00:00
m.serverSelection = "Saved"
2021-07-09 20:08:32 +00:00
if startOver or invalidServer
print "Get server details"
SendPerformanceBeacon("AppDialogInitiate") ' Roku Performance monitoring - Dialog Starting
2021-12-26 18:52:43 +00:00
m.serverSelection = CreateServerGroup()
2021-07-09 20:08:32 +00:00
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
2021-12-26 18:52:43 +00:00
if m.serverSelection = "backPressed"
2021-07-09 20:08:32 +00:00
print "backPressed"
2021-10-10 02:04:37 +00:00
m.global.sceneManager.callFunc("clearScenes")
2021-07-09 20:08:32 +00:00
return false
2020-03-21 21:22:26 +00:00
end if
2021-12-26 20:25:58 +00:00
SaveServerList()
2021-07-09 20:08:32 +00:00
end if
if get_setting("active_user") = invalid
SendPerformanceBeacon("AppDialogInitiate") ' Roku Performance monitoring - Dialog Starting
publicUsers = GetPublicUsers()
if publicUsers.count()
publicUsersNodes = []
for each item in publicUsers
user = CreateObject("roSGNode", "PublicUserData")
user.id = item.Id
user.name = item.Name
if item.PrimaryImageTag <> invalid
user.ImageURL = UserImageURL(user.id, { "tag": item.PrimaryImageTag })
end if
publicUsersNodes.push(user)
end for
userSelected = CreateUserSelectGroup(publicUsersNodes)
if userSelected = "backPressed"
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
return LoginFlow(true)
else
'Try to login without password. If the token is valid, we're done
get_token(userSelected, "")
if get_setting("active_user") <> invalid
m.user = AboutMe()
LoadUserPreferences()
2022-01-09 06:31:27 +00:00
LoadUserAbilities(m.user)
2021-07-09 20:08:32 +00:00
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
return true
end if
end if
else
userSelected = ""
end if
passwordEntry = CreateSigninGroup(userSelected)
2020-04-29 16:26:12 +00:00
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
2021-07-09 20:08:32 +00:00
if passwordEntry = "backPressed"
2021-12-30 03:51:39 +00:00
m.global.sceneManager.callFunc("clearScenes")
2021-07-09 20:08:32 +00:00
return LoginFlow(true)
2020-03-21 21:22:26 +00:00
end if
end if
2021-07-09 20:08:32 +00:00
m.user = AboutMe()
if m.user = invalid or m.user.id <> get_setting("active_user")
print "Login failed, restart flow"
unset_setting("active_user")
goto start_login
2020-03-21 21:22:26 +00:00
end if
2021-07-09 20:08:32 +00:00
LoadUserPreferences()
2022-01-09 06:31:27 +00:00
LoadUserAbilities(m.user)
2021-10-10 02:04:37 +00:00
m.global.sceneManager.callFunc("clearScenes")
2021-07-09 20:08:32 +00:00
'Send Device Profile information to server
body = getDeviceCapabilities()
req = APIRequest("/Sessions/Capabilities/Full")
req.SetRequest("POST")
postJson(req, FormatJson(body))
return true
2020-03-21 21:22:26 +00:00
end function
2019-10-05 07:50:05 +00:00
2021-12-23 01:00:47 +00:00
sub SaveServerList()
'Save off this server to our list of saved servers for easier navigation between servers
server = get_setting("server")
saved = get_setting("saved_servers")
2021-12-26 21:03:59 +00:00
if server <> invalid
server = LCase(server)'Saved server data is always lowercase
end if
2021-12-26 20:25:58 +00:00
entryCount = 0
addNewEntry = true
savedServers = { serverList: [] }
2021-12-26 20:41:32 +00:00
if saved <> invalid
2021-12-23 01:00:47 +00:00
savedServers = ParseJson(saved)
2021-12-26 20:41:32 +00:00
entryCount = savedServers.serverList.Count()
2021-12-26 20:25:58 +00:00
if savedServers.serverList <> invalid and entryCount > 0
for each item in savedServers.serverList
2021-12-26 21:03:59 +00:00
if item.baseUrl = server
2021-12-26 20:25:58 +00:00
addNewEntry = false
exit for
end if
end for
end if
end if
2021-12-26 20:41:32 +00:00
2021-12-26 20:25:58 +00:00
if addNewEntry
2021-12-26 20:41:32 +00:00
if entryCount = 0
2021-12-30 01:00:13 +00:00
set_setting("saved_servers", FormatJson({ serverList: [{ name: m.serverSelection, baseUrl: server, iconUrl: "pkg:/images/logo-icon120.jpg", iconWidth: 120, iconHeight: 120 }] }))
2021-12-26 20:25:58 +00:00
else
2021-12-30 01:00:13 +00:00
savedServers.serverList.Push({ name: m.serverSelection, baseUrl: server, iconUrl: "pkg:/images/logo-icon120.jpg", iconWidth: 120, iconHeight: 120 })
2021-12-23 01:00:47 +00:00
set_setting("saved_servers", FormatJson(savedServers))
end if
end if
end sub
sub DeleteFromServerList(urlToDelete)
saved = get_setting("saved_servers")
2021-12-26 21:03:59 +00:00
if urlToDelete <> invalid
urlToDelete = LCase(urlToDelete)
end if
2021-12-23 01:00:47 +00:00
if saved <> invalid
savedServers = ParseJson(saved)
2021-12-24 04:08:43 +00:00
newServers = { serverList: [] }
2021-12-23 01:00:47 +00:00
for each item in savedServers.serverList
2021-12-26 21:03:59 +00:00
if item.baseUrl <> urlToDelete
2021-12-23 01:00:47 +00:00
newServers.serverList.Push(item)
end if
end for
set_setting("saved_servers", FormatJson(newServers))
end if
end sub
2019-10-05 07:50:05 +00:00
sub RunScreenSaver()
2021-07-09 20:08:32 +00:00
print "Starting screensaver..."
2022-06-03 01:29:07 +00:00
scene = ReadAsciiFile("tmp:/scene")
if scene = "nowplaying" then return
2021-07-09 20:08:32 +00:00
screen = createObject("roSGScreen")
m.port = createObject("roMessagePort")
screen.setMessagePort(m.port)
screen.createScene("Screensaver")
screen.Show()
while true
msg = wait(8000, m.port)
if msg <> invalid
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
end if
end while
2019-10-05 07:50:05 +00:00
2019-10-13 19:33:14 +00:00
end sub
2020-05-05 21:09:18 +00:00
' Roku Performance monitoring
2020-04-29 16:26:12 +00:00
sub SendPerformanceBeacon(signalName as string)
2021-07-09 20:08:32 +00:00
if m.global.app_loaded = false
m.scene.signalBeacon(signalName)
end if
2021-07-09 10:21:24 +00:00
end sub