2019-01-30 04:19:27 +00:00
|
|
|
sub Main()
|
2019-05-02 17:45:07 +00:00
|
|
|
|
|
|
|
' If the Rooibos files are included in deployment, run tests
|
|
|
|
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")
|
|
|
|
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()
|
|
|
|
m.overhang = CreateObject("roSGNode", "JFOverhang")
|
|
|
|
|
2019-10-17 02:40:50 +00:00
|
|
|
m.page_size = 50
|
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
themeScene()
|
2019-03-06 02:28:52 +00:00
|
|
|
|
2019-04-22 19:08:10 +00:00
|
|
|
app_start:
|
2019-03-05 04:59:31 +00:00
|
|
|
' First thing to do is validate the ability to use the API
|
2019-04-22 19:08:10 +00:00
|
|
|
LoginFlow()
|
2019-03-05 04:31:58 +00:00
|
|
|
|
2019-10-12 20:21:34 +00:00
|
|
|
|
2019-04-22 19:08:10 +00:00
|
|
|
' Confirm the configured server and user work
|
2019-10-13 19:33:14 +00:00
|
|
|
group = CreateLibraryGroup()
|
2019-10-12 21:00:07 +00:00
|
|
|
m.overhang.title = group.overhangTitle
|
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)
|
|
|
|
|
|
|
|
' 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
|
2019-10-12 20:21:34 +00:00
|
|
|
while(true)
|
|
|
|
msg = wait(0, m.port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
print "CLOSING SCREEN"
|
|
|
|
return
|
|
|
|
else if isNodeEvent(msg, "backPressed")
|
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()
|
|
|
|
end if
|
2019-10-12 20:21:34 +00:00
|
|
|
' Pop a group off the stack and expose what's below
|
|
|
|
n = m.scene.getChildCount() - 1
|
2019-10-12 21:23:44 +00:00
|
|
|
if n = 1
|
|
|
|
' Overhang + last scene... this is the end
|
2019-10-12 20:21:34 +00:00
|
|
|
return
|
|
|
|
end if
|
|
|
|
m.scene.removeChildIndex(n)
|
|
|
|
group = m.scene.getChild(n - 1)
|
2019-10-12 21:00:07 +00:00
|
|
|
m.overhang.title = group.overhangTitle
|
|
|
|
m.overhang.visible = true
|
2019-10-12 20:21:34 +00:00
|
|
|
if group.lastFocus <> invalid
|
|
|
|
group.lastFocus.setFocus(true)
|
|
|
|
else
|
|
|
|
group.setFocus(true)
|
|
|
|
end if
|
|
|
|
group.visible = true
|
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
|
2019-10-12 20:21:34 +00:00
|
|
|
else if isNodeEvent(msg, "librarySelected")
|
|
|
|
' If you select a library from ANYWHERE, follow this flow
|
2019-10-12 21:00:07 +00:00
|
|
|
node = getMsgPicker(msg, "LibrarySelect")
|
2019-10-12 20:21:34 +00:00
|
|
|
if node.type = "movies"
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
2019-10-13 19:33:14 +00:00
|
|
|
group = CreateMovieListGroup(node)
|
2019-10-12 21:00:07 +00:00
|
|
|
m.overhang.title = group.overhangTitle
|
2019-10-12 20:21:34 +00:00
|
|
|
m.scene.appendChild(group)
|
2019-12-07 02:49:37 +00:00
|
|
|
else if node.type = "tvshows"
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
|
|
|
group = CreateSeriesListGroup(node)
|
|
|
|
m.overhang.title = group.overhangTitle
|
|
|
|
m.scene.appendChild(group)
|
2019-10-17 02:40:50 +00:00
|
|
|
else if node.type = "boxsets"
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
|
|
|
group = CreateCollectionsList(node)
|
|
|
|
m.overhang.title = group.overhangTitle
|
|
|
|
m.scene.appendChild(group)
|
2019-10-12 20:21:34 +00:00
|
|
|
else
|
2019-10-13 19:33:14 +00:00
|
|
|
' TODO - switch on more node types
|
|
|
|
message_dialog("This library type is not yet implemented: " + node.type)
|
2019-10-12 20:21:34 +00:00
|
|
|
end if
|
2019-10-17 02:40:50 +00:00
|
|
|
else if isNodeEvent(msg, "collectionSelected")
|
|
|
|
node = getMsgPicker(msg, "picker")
|
|
|
|
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
|
|
|
group = CreateMovieListGroup(node)
|
2019-10-17 02:42:49 +00:00
|
|
|
m.overhang.title = node.title
|
2019-10-17 02:40:50 +00:00
|
|
|
m.scene.appendChild(group)
|
2019-10-12 20:21:34 +00:00
|
|
|
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
|
|
|
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
2019-10-13 19:33:14 +00:00
|
|
|
group = CreateMovieDetailsGroup(node)
|
2019-10-12 20:21:34 +00:00
|
|
|
m.scene.appendChild(group)
|
2019-10-12 21:00:07 +00:00
|
|
|
m.overhang.title = group.overhangTitle
|
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")
|
|
|
|
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
|
|
|
group = CreateSeriesDetailsGroup(node)
|
|
|
|
m.scene.appendChild(group)
|
|
|
|
m.overhang.title = group.overhangTitle
|
|
|
|
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.lastFocus = group.focusedChild.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
|
|
|
group = CreateSeasonDetailsGroup(series.itemContent, node)
|
|
|
|
m.scene.appendChild(group)
|
|
|
|
m.overhang.title = group.overhangTitle
|
|
|
|
else if isNodeEvent(msg, "episodeSelected")
|
|
|
|
' If you select a TV Episode from ANYWHERE, follow this flow
|
|
|
|
node = getMsgPicker(msg, "picker")
|
|
|
|
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
video_id = node.id
|
|
|
|
|
|
|
|
group = CreateVideoPlayerGroup(video_id)
|
|
|
|
m.scene.appendChild(group)
|
|
|
|
group.setFocus(true)
|
|
|
|
group.control = "play"
|
2020-02-17 19:30:04 +00:00
|
|
|
ReportPlayback(group, "start")
|
2019-12-07 02:49:37 +00:00
|
|
|
m.overhang.visible = false
|
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)
|
|
|
|
|
|
|
|
results = SearchMedia(query)
|
|
|
|
options.itemData = results
|
|
|
|
options.query = query
|
2019-10-13 22:10:23 +00:00
|
|
|
else if isNodeEvent(msg, "pageSelected")
|
2019-10-14 16:25:05 +00:00
|
|
|
group.pageNumber = msg.getRoSGNode().pageSelected
|
2019-10-17 02:40:50 +00:00
|
|
|
if group.library = invalid
|
|
|
|
' Cover this case first to avoid "invalid.type" calls
|
|
|
|
else if group.library.type = "movies"
|
|
|
|
MovieLister(group, m.page_size)
|
|
|
|
else if group.library.type = "boxsets"
|
|
|
|
CollectionLister(group, m.page_size)
|
2020-02-15 17:56:56 +00:00
|
|
|
else if group.library.type = "tvshows"
|
|
|
|
SeriesLister(group, m.page_size)
|
2019-10-17 02:40:50 +00:00
|
|
|
end if
|
2019-10-14 16:41:20 +00:00
|
|
|
' TODO - abstract away the "picker" node
|
|
|
|
group.findNode("picker").setFocus(true)
|
2019-10-13 20:52:34 +00:00
|
|
|
else if isNodeEvent(msg, "itemSelected")
|
|
|
|
' Search item selected
|
|
|
|
node = getMsgPicker(msg)
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
|
|
|
' TODO - swap this based on target.mediatype
|
|
|
|
' types: [ Episode, Movie, Audio, Person, Studio, MusicArtist ]
|
|
|
|
group = CreateMovieDetailsGroup(node)
|
|
|
|
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)
|
|
|
|
if btn.id = "play-button"
|
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
|
|
|
|
group.lastFocus = group.focusedChild.focusedChild.focusedChild
|
2019-10-12 21:00:07 +00:00
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
video_id = group.id
|
|
|
|
|
2019-10-13 19:33:14 +00:00
|
|
|
group = CreateVideoPlayerGroup(video_id)
|
2019-10-12 21:00:07 +00:00
|
|
|
m.scene.appendChild(group)
|
|
|
|
group.setFocus(true)
|
|
|
|
group.control = "play"
|
2020-02-17 21:19:02 +00:00
|
|
|
ReportPlayback(group, "start")
|
2019-10-12 21:00:07 +00:00
|
|
|
m.overhang.visible = false
|
2019-10-15 01:30:10 +00:00
|
|
|
else if 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.id = "favorite-button"
|
|
|
|
movie = group.itemContent
|
|
|
|
if movie.favorite
|
|
|
|
UnmarkItemFavorite(movie.id)
|
|
|
|
else
|
|
|
|
MarkItemFavorite(movie.id)
|
|
|
|
end if
|
|
|
|
movie.favorite = not movie.favorite
|
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
|
|
|
|
group.lastFocus = group.focusedChild
|
|
|
|
group.setFocus(false)
|
|
|
|
group.visible = false
|
|
|
|
|
|
|
|
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
|
|
|
|
else if button.id = "add_user"
|
|
|
|
unset_setting("active_user")
|
|
|
|
unset_setting("server")
|
|
|
|
unset_setting("port")
|
|
|
|
wipe_groups()
|
|
|
|
goto app_start
|
|
|
|
end if
|
2020-02-18 01:08:51 +00:00
|
|
|
else if isNodeEvent(msg, "position")
|
|
|
|
video = msg.getRoSGNode()
|
|
|
|
if video.position >= video.duration then
|
|
|
|
video.control = "stop"
|
|
|
|
video.state = "finished"
|
|
|
|
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
|
|
|
|
node.backPressed = "true"
|
|
|
|
else if node.state = "playing" or node.state = "paused" then
|
|
|
|
ReportPlayback(group, "update")
|
|
|
|
end if
|
2019-10-12 20:21:34 +00:00
|
|
|
else
|
|
|
|
print type(msg)
|
|
|
|
print msg
|
|
|
|
end if
|
|
|
|
end while
|
2019-04-22 19:08:10 +00:00
|
|
|
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub LoginFlow()
|
2019-04-29 16:44:37 +00:00
|
|
|
'Collect Jellyfin server and user information
|
2019-03-06 02:28:52 +00:00
|
|
|
start_login:
|
2019-07-25 01:35:52 +00:00
|
|
|
if get_setting("server") = invalid or ServerInfo() = invalid then
|
2019-03-05 04:31:58 +00:00
|
|
|
print "Get server details"
|
2019-10-13 19:33:14 +00:00
|
|
|
CreateServerGroup()
|
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
|
|
|
|
print "Get user login"
|
2019-10-13 19:33:14 +00:00
|
|
|
CreateSigninGroup()
|
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
|
|
|
|
|
|
|
wipe_groups()
|
2019-01-30 04:19:27 +00:00
|
|
|
end sub
|
2019-10-05 07:50:05 +00:00
|
|
|
|
|
|
|
sub RunScreenSaver()
|
|
|
|
print "Starting screensaver..."
|
|
|
|
screen = createObject("roSGScreen")
|
|
|
|
m.port = createObject("roMessagePort")
|
|
|
|
screen.setMessagePort(m.port)
|
|
|
|
|
|
|
|
scene = 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-13 19:33:14 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
sub wipe_groups()
|
|
|
|
' The 1 remaining child should be the overhang
|
|
|
|
while(m.scene.getChildCount() > 1)
|
|
|
|
m.scene.removeChildIndex(1)
|
|
|
|
end while
|
2020-02-15 17:56:56 +00:00
|
|
|
end sub
|