Merge pull request #492 from jdlayman/group-stack
This commit is contained in:
commit
eacadf187c
|
@ -44,6 +44,36 @@ sub loadInitialItems()
|
|||
SetBackground(m.top.parentItem.backdropUrl)
|
||||
end if
|
||||
|
||||
' Read view/sort/filter settings
|
||||
if m.top.parentItem.collectionType = "livetv"
|
||||
' Translate between app and server nomenclature
|
||||
viewSetting = get_user_setting("display.livetv.landing")
|
||||
if viewSetting = "guide"
|
||||
m.view = "tvGuide"
|
||||
else
|
||||
m.view = "livetv"
|
||||
end if
|
||||
m.sortField = get_user_setting("display.livetv.sortField")
|
||||
sortAscendingStr = get_user_setting("display.livetv.sortAscending")
|
||||
m.filter = get_user_setting("display.livetv.filter")
|
||||
else
|
||||
m.view = invalid
|
||||
m.sortField = get_user_setting("display." + m.top.parentItem.Id + ".sortField")
|
||||
sortAscendingStr = get_user_setting("display." + m.top.parentItem.Id + ".sortAscending")
|
||||
m.filter = get_user_setting("display." + m.top.parentItem.Id + ".filter")
|
||||
end if
|
||||
|
||||
if m.sortField = invalid then m.sortField = "SortName"
|
||||
if m.filter = invalid then m.filter = "All"
|
||||
|
||||
if sortAscendingStr = invalid or sortAscendingStr = "true"
|
||||
m.sortAscending = true
|
||||
else
|
||||
m.sortAscending = false
|
||||
end if
|
||||
|
||||
updateTitle()
|
||||
|
||||
m.loadItemsTask.itemId = m.top.parentItem.Id
|
||||
m.loadItemsTask.sortField = m.sortField
|
||||
m.loadItemsTask.sortAscending = m.sortAscending
|
||||
|
@ -138,7 +168,7 @@ sub SetUpOptions()
|
|||
else if m.top.parentItem.collectionType = "livetv"
|
||||
options.views = [
|
||||
{ "Title": tr("Channels"), "Name": "livetv" },
|
||||
{ "Title": tr("TV Guide"), "Name": "tvGuide", "Selected": get_user_setting("display.livetv.landing") = "guide" }
|
||||
{ "Title": tr("TV Guide"), "Name": "tvGuide" }
|
||||
]
|
||||
options.sort = [
|
||||
{ "Title": tr("TITLE"), "Name": "SortName" }
|
||||
|
@ -157,16 +187,26 @@ sub SetUpOptions()
|
|||
options.filter = []
|
||||
end if
|
||||
|
||||
for each o in options.views
|
||||
if o.Name = m.view
|
||||
o.Selected = true
|
||||
o.Ascending = m.sortAscending
|
||||
m.options.view = o.Name
|
||||
end if
|
||||
end for
|
||||
|
||||
for each o in options.sort
|
||||
if o.Name = m.sortField
|
||||
o.Selected = true
|
||||
o.Ascending = m.sortAscending
|
||||
m.options.sortField = o.Name
|
||||
end if
|
||||
end for
|
||||
|
||||
for each o in options.filter
|
||||
if o.Name = m.filter
|
||||
o.Selected = true
|
||||
m.options.filter = o.Name
|
||||
end if
|
||||
end for
|
||||
|
||||
|
@ -293,12 +333,22 @@ end sub
|
|||
'Check if options updated and any reloading required
|
||||
sub optionsClosed()
|
||||
|
||||
if m.options.view = "tvGuide"
|
||||
showTVGuide()
|
||||
return
|
||||
else if m.tvGuide <> invalid
|
||||
' Try to hide the TV Guide
|
||||
m.top.removeChild(m.tvGuide)
|
||||
if m.top.parentItem.collectionType = "livetv" and m.options.view <> m.view
|
||||
if m.options.view = "tvGuide"
|
||||
m.view = "tvGuide"
|
||||
set_user_setting("display.livetv.landing", "guide")
|
||||
showTVGuide()
|
||||
return
|
||||
else
|
||||
m.view = "livetv"
|
||||
set_user_setting("display.livetv.landing", "channels")
|
||||
|
||||
if m.tvGuide <> invalid
|
||||
' Try to hide the TV Guide
|
||||
m.top.removeChild(m.tvGuide)
|
||||
end if
|
||||
end if
|
||||
|
||||
end if
|
||||
|
||||
reload = false
|
||||
|
@ -306,10 +356,33 @@ sub optionsClosed()
|
|||
m.sortField = m.options.sortField
|
||||
m.sortAscending = m.options.sortAscending
|
||||
reload = true
|
||||
|
||||
'Store sort settings
|
||||
if m.sortAscending = true
|
||||
sortAscendingStr = "true"
|
||||
else
|
||||
sortAscendingStr = "false"
|
||||
end if
|
||||
|
||||
if m.top.parentItem.collectionType = "livetv"
|
||||
set_user_setting("display.livetv.sortField", m.sortField)
|
||||
set_user_setting("display.livetv.sortAscending", sortAscendingStr)
|
||||
else
|
||||
set_user_setting("display." + m.top.parentItem.Id + ".sortField", m.sortField)
|
||||
set_user_setting("display." + m.top.parentItem.Id + ".sortAscending", sortAscendingStr)
|
||||
end if
|
||||
end if
|
||||
if m.options.filter <> m.filter
|
||||
m.filter = m.options.filter
|
||||
updateTitle()
|
||||
reload = true
|
||||
|
||||
'Store filter setting
|
||||
if m.top.parentItem.collectionType = "livetv"
|
||||
set_user_setting("display.livetv.filter", m.options.filter)
|
||||
else
|
||||
set_user_setting("display." + m.top.parentItem.Id + ".filter", m.options.filter)
|
||||
end if
|
||||
end if
|
||||
if reload
|
||||
m.loadedRows = 0
|
||||
|
@ -319,6 +392,9 @@ sub optionsClosed()
|
|||
loadInitialItems()
|
||||
end if
|
||||
m.itemGrid.setFocus(true)
|
||||
if m.tvGuide <> invalid
|
||||
m.tvGuide.lastFocus.setFocus(true)
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub showTVGuide()
|
||||
|
@ -327,7 +403,7 @@ sub showTVGuide()
|
|||
m.top.signalBeacon("EPGLaunchInitiate") ' Required Roku Performance monitoring
|
||||
m.tvGuide.observeField("watchChannel", "onChannelSelected")
|
||||
end if
|
||||
m.tvGuide.filter = m.options.filter
|
||||
m.tvGuide.filter = m.filter
|
||||
m.top.appendChild(m.tvGuide)
|
||||
m.tvGuide.lastFocus.setFocus(true)
|
||||
end sub
|
||||
|
@ -372,3 +448,13 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
|||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
sub updateTitle()
|
||||
if m.filter = "All"
|
||||
m.top.overhangTitle = m.top.parentItem.title
|
||||
else if m.filter = "Favorites"
|
||||
m.top.overhangTitle = m.top.parentItem.title + " (Favorites)"
|
||||
else
|
||||
m.top.overhangTitle = m.top.parentItem.title + " (Filtered)"
|
||||
end if
|
||||
end sub
|
|
@ -7,10 +7,16 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
|||
if not press then return false
|
||||
|
||||
if key = "back"
|
||||
m.top.backPressed = true
|
||||
m.global.sceneManager.callFunc("popScene")
|
||||
return true
|
||||
else if key = "options"
|
||||
m.top.optionsPressed = true
|
||||
group = m.global.sceneManager.callFunc("getActiveScene")
|
||||
if group.optionsAvailable
|
||||
group.lastFocus = group.focusedChild
|
||||
panel = group.findNode("options")
|
||||
panel.visible = true
|
||||
panel.findNode("panelList").setFocus(true)
|
||||
end if
|
||||
return true
|
||||
end if
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<component name="JFScene" extends="Scene">
|
||||
<children>
|
||||
<Group id="content" />
|
||||
<JFOverhang id="overhang" />
|
||||
</children>
|
||||
<interface>
|
||||
<field id="backPressed" type="boolean" alwaysNotify="true" />
|
||||
<field id="optionsPressed" type="boolean" alwaysNotify="true" />
|
||||
<field id="exit" type="boolean" alwaysNotify="true" />
|
||||
</interface>
|
||||
<script type="text/brightscript" uri="JFScene.brs" />
|
||||
</component>
|
||||
|
|
175
components/data/SceneManager.brs
Executable file
175
components/data/SceneManager.brs
Executable file
|
@ -0,0 +1,175 @@
|
|||
sub init()
|
||||
m.groups = []
|
||||
m.scene = m.top.getScene()
|
||||
m.content = m.scene.findNode("content")
|
||||
m.overhang = m.scene.findNode("overhang")
|
||||
end sub
|
||||
|
||||
'
|
||||
' Push a new group onto the stack, replacing the existing group on the screen
|
||||
sub pushScene(newGroup)
|
||||
currentGroup = m.groups.peek()
|
||||
if currentGroup <> invalid
|
||||
'Search through group and store off last focused item
|
||||
if currentGroup.focusedChild <> invalid
|
||||
focused = currentGroup.focusedChild
|
||||
while focused.hasFocus() = false
|
||||
focused = focused.focusedChild
|
||||
end while
|
||||
currentGroup.lastFocus = focused
|
||||
currentGroup.setFocus(false)
|
||||
else
|
||||
currentGroup.lastFocus = invalid
|
||||
currentGroup.setFocus(false)
|
||||
end if
|
||||
|
||||
if currentGroup.isSubType("JFGroup")
|
||||
unregisterOverhangData(currentGroup)
|
||||
end if
|
||||
|
||||
currentGroup.visible = false
|
||||
end if
|
||||
|
||||
m.groups.push(newGroup)
|
||||
|
||||
if currentGroup <> invalid
|
||||
m.content.replaceChild(newGroup, 0)
|
||||
else
|
||||
m.content.appendChild(newGroup)
|
||||
end if
|
||||
|
||||
'observe info about new group, set overhang title, etc.
|
||||
if newGroup.isSubType("JFGroup")
|
||||
registerOverhangData(newGroup)
|
||||
|
||||
' Some groups set focus to a specific component within init(), so we don't want to
|
||||
' change if that is the case.
|
||||
if newGroup.isInFocusChain() = false
|
||||
newGroup.setFocus(true)
|
||||
end if
|
||||
else if newGroup.isSubType("JFVideo")
|
||||
newGroup.setFocus(true)
|
||||
newGroup.control = "play"
|
||||
m.overhang.visible = false
|
||||
end if
|
||||
end sub
|
||||
|
||||
'
|
||||
' Remove the current group and load the last group from the stack
|
||||
sub popScene()
|
||||
group = m.groups.pop()
|
||||
if group <> invalid
|
||||
if group.isSubType("JFGroup")
|
||||
unregisterOverhangData(group)
|
||||
else if group.isSubType("JFVideo")
|
||||
' Stop video to make sure app communicates stop playstate to server
|
||||
group.control = "stop"
|
||||
end if
|
||||
else
|
||||
' Exit app if for some reason we don't have anything on the stack
|
||||
m.scene.exit = true
|
||||
end if
|
||||
|
||||
group = m.groups.peek()
|
||||
if group <> invalid
|
||||
registerOverhangData(group)
|
||||
|
||||
if group.subtype() = "Home"
|
||||
currentTime = CreateObject("roDateTime").AsSeconds()
|
||||
if group.timeLastRefresh = invalid or (currentTime - group.timeLastRefresh) > 20
|
||||
group.timeLastRefresh = currentTime
|
||||
group.callFunc("refresh")
|
||||
end if
|
||||
end if
|
||||
|
||||
group.visible = true
|
||||
|
||||
m.content.replaceChild(group, 0)
|
||||
|
||||
' Restore focus
|
||||
if group.lastFocus <> invalid
|
||||
group.lastFocus.setFocus(true)
|
||||
else
|
||||
group.setFocus(true)
|
||||
end if
|
||||
else
|
||||
' Exit app if the stack is empty after removing group
|
||||
m.scene.exit = true
|
||||
end if
|
||||
|
||||
end sub
|
||||
|
||||
|
||||
'
|
||||
' Return group at top of stack without removing
|
||||
function getActiveScene() as object
|
||||
return m.groups.peek()
|
||||
end function
|
||||
|
||||
|
||||
'
|
||||
' Clear all content from group stack
|
||||
sub clearScenes()
|
||||
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
|
||||
m.groups = []
|
||||
end sub
|
||||
|
||||
|
||||
'
|
||||
' Register observers for overhang data
|
||||
sub registerOverhangData(group)
|
||||
if group.isSubType("JFGroup")
|
||||
if group.overhangTitle <> invalid then m.overhang.title = group.overhangTitle
|
||||
|
||||
if group.optionsAvailable
|
||||
m.overhang.showOptions = true
|
||||
else
|
||||
m.overhang.showOptions = false
|
||||
end if
|
||||
group.observeField("optionsAvailable", "updateOptions")
|
||||
|
||||
group.observeField("overhangTitle", "updateOverhangTitle")
|
||||
m.overhang.visible = true
|
||||
else if group.isSubType("JFVideo")
|
||||
m.overhang.visible = false
|
||||
else
|
||||
print "registerOverhangData(): Unexpected group type."
|
||||
end if
|
||||
end sub
|
||||
|
||||
|
||||
'
|
||||
' Remove observers for overhang data
|
||||
sub unregisterOverhangData(group)
|
||||
group.unobserveField("overhangTitle")
|
||||
end sub
|
||||
|
||||
|
||||
'
|
||||
' Update overhang title
|
||||
sub updateOverhangTitle(msg)
|
||||
m.overhang.title = msg.getData()
|
||||
end sub
|
||||
|
||||
|
||||
'
|
||||
' Update options availability
|
||||
sub updateOptions(msg)
|
||||
m.overhang.showOptions = msg.getData()
|
||||
end sub
|
||||
|
||||
|
||||
'
|
||||
' Update username in overhang
|
||||
sub updateUser()
|
||||
' Passthrough to overhang
|
||||
m.overhang.currentUser = m.top.currentUser
|
||||
end sub
|
||||
|
||||
|
||||
'
|
||||
' Reset time
|
||||
sub resetTime()
|
||||
' Passthrough to overhang
|
||||
m.overhang.callFunc("resetTime")
|
||||
end sub
|
12
components/data/SceneManager.xml
Executable file
12
components/data/SceneManager.xml
Executable file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<component name="SceneManager" extends="ContentNode">
|
||||
<interface>
|
||||
<function name="pushScene" />
|
||||
<function name="popScene" />
|
||||
<function name="getActiveScene" />
|
||||
<function name="clearScenes" />
|
||||
<function name="resetTime" />
|
||||
<field id="currentUser" type="string" onChange="updateUser" />
|
||||
</interface>
|
||||
<script type="text/brightscript" uri="SceneManager.brs" />
|
||||
</component>
|
|
@ -3,8 +3,8 @@
|
|||
<children>
|
||||
|
||||
<!-- Selected Item Details -->
|
||||
<maskGroup id="backgroundMask" maskUri="pkg:/images/backgroundmask.png" translation="[1208, 127]" maskSize="[712,400]">
|
||||
<Poster id="image" height="400" width="712" loadDisplayMode="scaleToFit" />
|
||||
<maskGroup id="backgroundMask" maskUri="pkg:/images/backgroundmask.png" translation="[1320, 150]" maskSize="[500,375]">
|
||||
<Poster id="image" height="375" width="500" loadDisplayMode="scaleToFit" />
|
||||
</maskGroup>
|
||||
|
||||
<Group id="detailsView" visible="false">
|
||||
|
@ -32,7 +32,7 @@
|
|||
<Label id="channelName" />
|
||||
</LayoutGroup>
|
||||
|
||||
<label id="overview" wrap="true" width="1250" font="font:SmallestSystemFont" />
|
||||
<label id="overview" wrap="true" width="1210" font="font:SmallestSystemFont" />
|
||||
|
||||
<!-- View Channel button -->
|
||||
<Group id="viewChannelButton" opacity="0">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<component name="Schedule" extends="JFGroup">
|
||||
<children>
|
||||
<rectangle translation="[0,125]" width="1920" height="955" color="#262626" />
|
||||
<rectangle translation="[0,150]" width="1920" height="930" color="#262626" />
|
||||
|
||||
<!-- Selected Item Details -->
|
||||
<ProgramDetails id="detailsPane" focusable="true" />
|
||||
|
|
240
source/Main.brs
240
source/Main.brs
|
@ -21,30 +21,23 @@ sub Main (args as dynamic) as void
|
|||
playstateTask = CreateObject("roSGNode", "PlaystateTask")
|
||||
playstateTask.id = "playstateTask"
|
||||
|
||||
m.global.addFields({ app_loaded: false, playstateTask: playstateTask })
|
||||
sceneManager = CreateObject("roSGNode", "SceneManager")
|
||||
|
||||
m.overhang = CreateObject("roSGNode", "JFOverhang")
|
||||
m.scene.insertChild(m.overhang, 0)
|
||||
m.global.addFields({ app_loaded: false, playstateTask: playstateTask, sceneManager: sceneManager })
|
||||
|
||||
app_start:
|
||||
m.overhang.title = ""
|
||||
' First thing to do is validate the ability to use the API
|
||||
|
||||
if not LoginFlow() then return
|
||||
wipe_groups()
|
||||
sceneManager.callFunc("clearScenes")
|
||||
|
||||
' load home page
|
||||
m.overhang.title = tr("Home")
|
||||
m.overhang.currentUser = m.user.Name
|
||||
m.overhang.showOptions = true
|
||||
sceneManager.currentUser = m.user.Name
|
||||
group = CreateHomeGroup()
|
||||
group.userConfig = m.user.configuration
|
||||
group.callFunc("loadLibraries")
|
||||
m.scene.appendChild(group)
|
||||
sceneManager.callFunc("pushScene", group)
|
||||
|
||||
m.scene.observeField("backPressed", m.port)
|
||||
m.scene.observeField("optionsPressed", m.port)
|
||||
m.scene.observeField("mutePressed", m.port)
|
||||
m.scene.observeField("exit", m.port)
|
||||
|
||||
' Handle input messages
|
||||
input = CreateObject("roInput")
|
||||
|
@ -53,20 +46,14 @@ sub Main (args as dynamic) as void
|
|||
m.device = CreateObject("roDeviceInfo")
|
||||
m.device.setMessagePort(m.port)
|
||||
m.device.EnableScreensaverExitedEvent(true)
|
||||
m.device.EnableAppFocusEvent(false)
|
||||
|
||||
' 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
|
||||
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"
|
||||
m.overhang.visible = false
|
||||
sceneManager.callFunc("pushScene", video)
|
||||
else
|
||||
dialog = createObject("roSGNode", "Dialog")
|
||||
dialog.id = "OKDialog"
|
||||
|
@ -87,23 +74,10 @@ sub Main (args as dynamic) as void
|
|||
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
|
||||
print "CLOSING SCREEN"
|
||||
return
|
||||
|
||||
else if isNodeEvent(msg, "backPressed")
|
||||
n = m.scene.getChildCount() - 1
|
||||
if msg.getRoSGNode().focusedChild <> invalid and msg.getRoSGNode().focusedChild.isSubtype("JFVideo")
|
||||
stopPlayback()
|
||||
RemoveCurrentGroup()
|
||||
else
|
||||
if n = 1 then return
|
||||
RemoveCurrentGroup()
|
||||
end if
|
||||
group = m.scene.getChild(n - 1)
|
||||
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, "exit")
|
||||
return
|
||||
else if isNodeEvent(msg, "closeSidePanel")
|
||||
group = sceneManager.callFunc("getActiveScene")
|
||||
if group.lastFocus <> invalid
|
||||
group.lastFocus.setFocus(true)
|
||||
else
|
||||
|
@ -116,67 +90,28 @@ sub Main (args as dynamic) as void
|
|||
if itemNode.type = "Episode" or itemNode.type = "Movie" or itemNode.type = "Video"
|
||||
video = CreateVideoPlayerGroup(itemNode.id)
|
||||
if video <> invalid
|
||||
group.lastFocus = group.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
group = video
|
||||
m.scene.appendChild(group)
|
||||
group.setFocus(true)
|
||||
group.control = "play"
|
||||
m.overhang.visible = false
|
||||
sceneManager.callFunc("pushScene", video)
|
||||
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.lastFocus = group.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
m.overhang.title = selectedItem.title
|
||||
group = CreateItemGrid(selectedItem)
|
||||
group.overhangTitle = selectedItem.title
|
||||
m.scene.appendChild(group)
|
||||
sceneManager.callFunc("pushScene", group)
|
||||
else if selectedItem.type = "Episode"
|
||||
' play episode
|
||||
' todo: create an episode page to link here
|
||||
video_id = selectedItem.id
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
video = CreateVideoPlayerGroup(video_id)
|
||||
if video <> invalid
|
||||
group.lastFocus = group.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
group = video
|
||||
m.scene.appendChild(group)
|
||||
group.setFocus(true)
|
||||
group.control = "play"
|
||||
m.overhang.visible = false
|
||||
sceneManager.callFunc("pushScene", video)
|
||||
end if
|
||||
else if selectedItem.type = "Series"
|
||||
group.lastFocus = group.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
|
||||
m.overhang.title = selectedItem.title
|
||||
m.overhang.showOptions = false
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
group = CreateSeriesDetailsGroup(selectedItem.json)
|
||||
group.overhangTitle = selectedItem.title
|
||||
m.scene.appendChild(group)
|
||||
else if selectedItem.type = "Movie"
|
||||
' open movie detail page
|
||||
group.lastFocus = group.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
|
||||
m.overhang.title = selectedItem.title
|
||||
m.overhang.showOptions = false
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
group = CreateMovieDetailsGroup(selectedItem)
|
||||
group.overhangTitle = selectedItem.title
|
||||
m.scene.appendChild(group)
|
||||
|
||||
else if selectedItem.type = "TvChannel" or selectedItem.type = "Video"
|
||||
' play channel feed
|
||||
video_id = selectedItem.id
|
||||
|
@ -186,19 +121,11 @@ sub Main (args as dynamic) as void
|
|||
dialog.title = tr("Loading Channel Data")
|
||||
m.scene.dialog = dialog
|
||||
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
video = CreateVideoPlayerGroup(video_id)
|
||||
dialog.close = true
|
||||
|
||||
if video <> invalid
|
||||
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"
|
||||
m.overhang.visible = false
|
||||
sceneManager.callFunc("pushScene", video)
|
||||
else
|
||||
dialog = createObject("roSGNode", "Dialog")
|
||||
dialog.id = "OKDialog"
|
||||
|
@ -215,62 +142,25 @@ sub Main (args as dynamic) as void
|
|||
else if isNodeEvent(msg, "movieSelected")
|
||||
' If you select a movie from ANYWHERE, follow this flow
|
||||
node = getMsgPicker(msg, "picker")
|
||||
|
||||
group.lastFocus = group.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
|
||||
m.overhang.title = node.title
|
||||
m.overhang.showOptions = false
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
group = CreateMovieDetailsGroup(node)
|
||||
group.overhangTitle = node.title
|
||||
m.scene.appendChild(group)
|
||||
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
|
||||
|
||||
m.overhang.title = node.title
|
||||
m.overhang.showOptions = false
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
group = CreateSeriesDetailsGroup(node)
|
||||
group.overhangTitle = node.title
|
||||
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]]
|
||||
|
||||
group.lastFocus = group.focusedChild.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
|
||||
m.overhang.title = series.overhangTitle + " - " + node.title
|
||||
m.overhang.showOptions = false
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
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
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
video = CreateVideoPlayerGroup(video_id)
|
||||
if video <> invalid
|
||||
group.lastFocus = group.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
group = video
|
||||
m.scene.appendChild(group)
|
||||
group.setFocus(true)
|
||||
group.control = "play"
|
||||
m.overhang.visible = false
|
||||
sceneManager.callFunc("pushScene", video)
|
||||
end if
|
||||
else if isNodeEvent(msg, "search_value")
|
||||
query = msg.getRoSGNode().search_value
|
||||
|
@ -289,10 +179,6 @@ sub Main (args as dynamic) as void
|
|||
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: [ Series (Show), Episode, Movie, Audio, Person, Studio, MusicArtist ]
|
||||
if node.type = "Series"
|
||||
|
@ -300,12 +186,10 @@ sub Main (args as dynamic) as void
|
|||
else
|
||||
group = CreateMovieDetailsGroup(node)
|
||||
end if
|
||||
m.scene.appendChild(group)
|
||||
m.overhang.title = group.overhangTitle
|
||||
|
||||
else if isNodeEvent(msg, "buttonSelected")
|
||||
' If a button is selected, we have some determining to do
|
||||
btn = getButton(msg)
|
||||
group = sceneManager.callFunc("getActiveScene")
|
||||
if btn <> invalid and btn.id = "play-button"
|
||||
' Check is a specific Audio Stream was selected
|
||||
audio_stream_idx = 1
|
||||
|
@ -313,19 +197,10 @@ sub Main (args as dynamic) as void
|
|||
audio_stream_idx = group.selectedAudioStreamIndex
|
||||
end if
|
||||
|
||||
' TODO - Do a better job of picking the last focus
|
||||
' This is currently page layout Group, button Group, then button
|
||||
video_id = group.id
|
||||
video = CreateVideoPlayerGroup(video_id, audio_stream_idx)
|
||||
if video <> invalid
|
||||
group.lastFocus = group.focusedChild.focusedChild.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
group = video
|
||||
m.scene.appendChild(group)
|
||||
group.setFocus(true)
|
||||
group.control = "play"
|
||||
m.overhang.visible = false
|
||||
sceneManager.callFunc("pushScene", video)
|
||||
end if
|
||||
else if btn <> invalid and btn.id = "watched-button"
|
||||
movie = group.itemContent
|
||||
|
@ -353,33 +228,29 @@ sub Main (args as dynamic) as void
|
|||
end if
|
||||
else if isNodeEvent(msg, "optionSelected")
|
||||
button = msg.getRoSGNode()
|
||||
group = sceneManager.callFunc("getActiveScene")
|
||||
if button.id = "goto_search"
|
||||
' 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
|
||||
group.lastFocus = group.focusedChild
|
||||
group.setFocus(false)
|
||||
group.visible = false
|
||||
m.overhang.showOptions = false
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
group = CreateSearchPage()
|
||||
m.scene.appendChild(group)
|
||||
m.overhang.title = group.overhangTitle
|
||||
sceneManager.callFunc("pushScene", group)
|
||||
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")
|
||||
SignOut()
|
||||
wipe_groups()
|
||||
sceneManager.callFunc("clearScenes")
|
||||
goto app_start
|
||||
else if button.id = "sign_out"
|
||||
SignOut()
|
||||
wipe_groups()
|
||||
sceneManager.callFunc("clearScenes")
|
||||
goto app_start
|
||||
else if button.id = "play_mpeg2"
|
||||
playMpeg2 = get_setting("playback.mpeg2")
|
||||
|
@ -403,18 +274,18 @@ sub Main (args as dynamic) as void
|
|||
else if isNodeEvent(msg, "state")
|
||||
node = msg.getRoSGNode()
|
||||
if node.state = "finished"
|
||||
stopPlayback()
|
||||
node.control = "stop"
|
||||
if node.showID = invalid
|
||||
RemoveCurrentGroup()
|
||||
sceneManager.callFunc("popScene")
|
||||
else
|
||||
nextEpisode = autoPlayNextEpisode(node.id, node.showID)
|
||||
if nextEpisode <> invalid then group = nextEpisode
|
||||
autoPlayNextEpisode(node.id, node.showID)
|
||||
end if
|
||||
end if
|
||||
else if type(msg) = "roDeviceInfoEvent"
|
||||
event = msg.GetInfo()
|
||||
group = sceneManager.callFunc("getActiveScene")
|
||||
if event.exitedScreensaver = true
|
||||
m.overhang.callFunc("resetTime")
|
||||
sceneManager.callFunc("resetTime")
|
||||
if group.subtype() = "Home"
|
||||
currentTime = CreateObject("roDateTime").AsSeconds()
|
||||
group.timeLastRefresh = currentTime
|
||||
|
@ -431,14 +302,7 @@ sub Main (args as dynamic) as void
|
|||
if info.DoesExist("mediatype") and info.DoesExist("contentid")
|
||||
video = CreateVideoPlayerGroup(info.contentId)
|
||||
if video <> invalid
|
||||
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"
|
||||
m.overhang.visible = false
|
||||
sceneManager.callFunc("pushScene", video)
|
||||
else
|
||||
dialog = createObject("roSGNode", "Dialog")
|
||||
dialog.id = "OKDialog"
|
||||
|
@ -459,9 +323,6 @@ sub Main (args as dynamic) as void
|
|||
end sub
|
||||
|
||||
function LoginFlow(startOver = false as boolean)
|
||||
if m.scene <> invalid
|
||||
m.scene.unobserveField("backPressed")
|
||||
end if
|
||||
'Collect Jellyfin server and user information
|
||||
start_login:
|
||||
|
||||
|
@ -484,7 +345,7 @@ function LoginFlow(startOver = false as boolean)
|
|||
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
|
||||
if serverSelection = "backPressed"
|
||||
print "backPressed"
|
||||
wipe_groups()
|
||||
m.global.sceneManager.callFunc("clearScenes")
|
||||
return false
|
||||
end if
|
||||
end if
|
||||
|
@ -537,7 +398,7 @@ function LoginFlow(startOver = false as boolean)
|
|||
end if
|
||||
|
||||
LoadUserPreferences()
|
||||
wipe_groups()
|
||||
m.global.sceneManager.callFunc("clearScenes")
|
||||
|
||||
'Send Device Profile information to server
|
||||
body = getDeviceCapabilities()
|
||||
|
@ -568,45 +429,6 @@ sub RunScreenSaver()
|
|||
|
||||
end sub
|
||||
|
||||
sub wipe_groups()
|
||||
' The 1 remaining child should be the overhang
|
||||
while m.scene.getChildCount() > 1
|
||||
m.scene.removeChildIndex(1)
|
||||
end while
|
||||
end sub
|
||||
|
||||
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
|
||||
if group.optionsAvailable = false
|
||||
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
|
||||
if group.subtype() = "Home"
|
||||
currentTime = CreateObject("roDateTime").AsSeconds()
|
||||
if group.timeLastRefresh = invalid or (currentTime - group.timeLastRefresh) > 20
|
||||
group.timeLastRefresh = currentTime
|
||||
group.callFunc("refresh")
|
||||
end if
|
||||
end if
|
||||
group.visible = true
|
||||
end sub
|
||||
|
||||
' Roku Performance monitoring
|
||||
sub SendPerformanceBeacon(signalName as string)
|
||||
if m.global.app_loaded = false
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function CreateServerGroup()
|
||||
screen = CreateObject("roSGNode", "SetServerScreen")
|
||||
m.scene.appendChild(screen)
|
||||
m.global.sceneManager.callFunc("pushScene", screen)
|
||||
port = CreateObject("roMessagePort")
|
||||
m.colors = {}
|
||||
|
||||
|
@ -75,7 +75,7 @@ function CreateUserSelectGroup(users = [])
|
|||
return ""
|
||||
end if
|
||||
group = CreateObject("roSGNode", "UserSelect")
|
||||
m.scene.appendChild(group)
|
||||
m.global.sceneManager.callFunc("pushScene", group)
|
||||
port = CreateObject("roMessagePort")
|
||||
|
||||
group.itemContent = users
|
||||
|
@ -106,7 +106,7 @@ end function
|
|||
function CreateSigninGroup(user = "")
|
||||
' Get and Save Jellyfin user login credentials
|
||||
group = CreateObject("roSGNode", "ConfigScene")
|
||||
m.scene.appendChild(group)
|
||||
m.global.sceneManager.callFunc("pushScene", group)
|
||||
port = CreateObject("roMessagePort")
|
||||
|
||||
group.findNode("prompt").text = tr("Sign In")
|
||||
|
@ -174,6 +174,8 @@ end function
|
|||
function CreateHomeGroup()
|
||||
' Main screen after logging in. Shows the user's libraries
|
||||
group = CreateObject("roSGNode", "Home")
|
||||
group.overhangTitle = tr("Home")
|
||||
group.optionsAvailable = true
|
||||
|
||||
group.observeField("selectedItem", m.port)
|
||||
group.observeField("quickPlayNode", m.port)
|
||||
|
@ -230,6 +232,9 @@ end function
|
|||
|
||||
function CreateMovieDetailsGroup(movie)
|
||||
group = CreateObject("roSGNode", "MovieDetails")
|
||||
group.overhangTitle = movie.title
|
||||
group.optionsAvailable = false
|
||||
m.global.sceneManager.callFunc("pushScene", group)
|
||||
|
||||
movie = ItemMetaData(movie.id)
|
||||
group.itemContent = movie
|
||||
|
@ -244,6 +249,9 @@ end function
|
|||
|
||||
function CreateSeriesDetailsGroup(series)
|
||||
group = CreateObject("roSGNode", "TVShowDetails")
|
||||
group.overhangTitle = series.title
|
||||
group.optionsAvailable = false
|
||||
m.global.sceneManager.callFunc("pushScene", group)
|
||||
|
||||
group.itemContent = ItemMetaData(series.id)
|
||||
group.seasonData = TVSeasons(series.id)
|
||||
|
@ -255,6 +263,9 @@ end function
|
|||
|
||||
function CreateSeasonDetailsGroup(series, season)
|
||||
group = CreateObject("roSGNode", "TVEpisodes")
|
||||
group.overhangTitle = series.title + " " + season.title
|
||||
group.optionsAvailable = false
|
||||
m.global.sceneManager.callFunc("pushScene", group)
|
||||
|
||||
group.seasonData = ItemMetaData(season.id).json
|
||||
group.objects = TVEpisodes(series.id, season.id)
|
||||
|
@ -268,6 +279,7 @@ end function
|
|||
function CreateItemGrid(libraryItem)
|
||||
group = CreateObject("roSGNode", "ItemGrid")
|
||||
group.parentItem = libraryItem
|
||||
group.optionsAvailable = true
|
||||
group.observeField("selectedItem", m.port)
|
||||
return group
|
||||
end function
|
||||
|
@ -295,7 +307,6 @@ function CreateVideoPlayerGroup(video_id, audio_stream_idx = 1)
|
|||
' Video is Playing
|
||||
video = VideoPlayer(video_id, audio_stream_idx)
|
||||
if video = invalid then return invalid
|
||||
video.observeField("backPressed", m.port)
|
||||
video.observeField("selectSubtitlePressed", m.port)
|
||||
video.observeField("state", m.port)
|
||||
|
||||
|
|
|
@ -208,13 +208,7 @@ function getAudioInfo(meta as object) as object
|
|||
return results
|
||||
end function
|
||||
|
||||
sub StopPlayback()
|
||||
video = m.scene.focusedchild
|
||||
video.control = "stop"
|
||||
m.device.EnableAppFocusEvent(False)
|
||||
end sub
|
||||
|
||||
function autoPlayNextEpisode(videoID as string, showID as string)
|
||||
sub autoPlayNextEpisode(videoID as string, showID as string)
|
||||
' use web client setting
|
||||
if m.user.Configuration.EnableNextEpisodeAutoPlay
|
||||
' query API for next episode ID
|
||||
|
@ -227,20 +221,19 @@ function autoPlayNextEpisode(videoID as string, showID as string)
|
|||
|
||||
if data <> invalid and data.Items.Count() = 2
|
||||
' remove finished video node
|
||||
n = m.scene.getChildCount() - 1
|
||||
m.scene.removeChildIndex(n)
|
||||
m.global.sceneManager.callFunc("popScene")
|
||||
' setup new video node
|
||||
nextVideo = CreateVideoPlayerGroup(data.Items[1].Id)
|
||||
m.scene.appendChild(nextVideo)
|
||||
nextVideo.setFocus(true)
|
||||
nextVideo.control = "play"
|
||||
return nextVideo
|
||||
if nextVideo <> invalid
|
||||
m.global.sceneManager.callFunc("pushScene", nextVideo)
|
||||
else
|
||||
m.global.sceneManager.callFunc("popScene")
|
||||
end if
|
||||
else
|
||||
' can't play next episode
|
||||
RemoveCurrentGroup()
|
||||
m.global.sceneManager.callFunc("popScene")
|
||||
end if
|
||||
else
|
||||
RemoveCurrentGroup()
|
||||
m.global.sceneManager.callFunc("popScene")
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
end sub
|
||||
|
|
|
@ -28,9 +28,9 @@ sub SignOut()
|
|||
unset_setting("password")
|
||||
end if
|
||||
unset_setting("active_user")
|
||||
m.overhang.currentUser = ""
|
||||
m.overhang.showOptions = false
|
||||
m.scene.unobserveField("optionsPressed")
|
||||
m.global.sceneManager.currentUser = ""
|
||||
group = m.global.sceneManager.callFunc("getActiveScene")
|
||||
group.optionsAvailable = false
|
||||
end sub
|
||||
|
||||
function AvailableUsers()
|
||||
|
|
|
@ -102,8 +102,6 @@ end function
|
|||
|
||||
function show_dialog(message as string, options = [], defaultSelection = 0) as integer
|
||||
lastFocus = lastFocusedChild(m.scene)
|
||||
'We want to handle backPressed instead of the main loop
|
||||
m.scene.unobserveField("backPressed")
|
||||
|
||||
dialog = createObject("roSGNode", "JFMessageDialog")
|
||||
if options.count() then dialog.options = options
|
||||
|
@ -131,7 +129,6 @@ function show_dialog(message as string, options = [], defaultSelection = 0) as i
|
|||
|
||||
m.scene.removeChildIndex(m.scene.getChildCount() - 1)
|
||||
lastFocus.setFocus(true)
|
||||
m.scene.observeField("backPressed", m.port)
|
||||
|
||||
return result
|
||||
end function
|
||||
|
|
Loading…
Reference in New Issue
Block a user