Add groups to stack to manage active group for main scene
This commit is contained in:
parent
e23f3ff8ac
commit
be24a19c8f
|
@ -7,10 +7,16 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
||||||
if not press then return false
|
if not press then return false
|
||||||
|
|
||||||
if key = "back"
|
if key = "back"
|
||||||
m.top.backPressed = true
|
m.global.groupStack.callFunc("pop")
|
||||||
return true
|
return true
|
||||||
else if key = "options"
|
else if key = "options"
|
||||||
m.top.optionsPressed = true
|
group = m.global.groupStack.callFunc("peek")
|
||||||
|
if group.optionsAvailable
|
||||||
|
group.lastFocus = group.focusedChild
|
||||||
|
panel = group.findNode("options")
|
||||||
|
panel.visible = true
|
||||||
|
panel.findNode("panelList").setFocus(true)
|
||||||
|
end if
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<component name="JFScene" extends="Scene">
|
<component name="JFScene" extends="Scene">
|
||||||
|
<children>
|
||||||
|
<JFOverhang id="overhang" />
|
||||||
|
</children>
|
||||||
<interface>
|
<interface>
|
||||||
<field id="backPressed" type="boolean" alwaysNotify="true" />
|
<field id="exit" type="boolean" alwaysNotify="true" />
|
||||||
<field id="optionsPressed" type="boolean" alwaysNotify="true" />
|
|
||||||
</interface>
|
</interface>
|
||||||
<script type="text/brightscript" uri="JFScene.brs" />
|
<script type="text/brightscript" uri="JFScene.brs" />
|
||||||
</component>
|
</component>
|
||||||
|
|
144
components/data/GroupStack.brs
Executable file
144
components/data/GroupStack.brs
Executable file
|
@ -0,0 +1,144 @@
|
||||||
|
sub init()
|
||||||
|
m.groups = []
|
||||||
|
m.scene = m.top.getScene()
|
||||||
|
m.overhang = m.scene.findNode("overhang")
|
||||||
|
end sub
|
||||||
|
|
||||||
|
'
|
||||||
|
' Push a new group onto the stack, replacing the existing group on the screen
|
||||||
|
sub push(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)
|
||||||
|
|
||||||
|
'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
|
||||||
|
|
||||||
|
' TODO: figure out a better way to do this without relying on indexing
|
||||||
|
if currentGroup <> invalid
|
||||||
|
m.scene.replaceChild(newGroup, 1)
|
||||||
|
else
|
||||||
|
m.scene.appendChild(newGroup)
|
||||||
|
end if
|
||||||
|
end sub
|
||||||
|
|
||||||
|
'
|
||||||
|
' Remove the current group and load the last group from the stack
|
||||||
|
sub pop()
|
||||||
|
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)
|
||||||
|
'm.scene.callFunc("registerOverhangData")
|
||||||
|
|
||||||
|
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.scene.replaceChild(group, 1)
|
||||||
|
|
||||||
|
' 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 peek() as object
|
||||||
|
return m.groups.peek()
|
||||||
|
end function
|
||||||
|
|
||||||
|
|
||||||
|
'
|
||||||
|
' 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("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
|
9
components/data/GroupStack.xml
Executable file
9
components/data/GroupStack.xml
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<component name="GroupStack" extends="ContentNode">
|
||||||
|
<interface>
|
||||||
|
<function name="push" />
|
||||||
|
<function name="pop" />
|
||||||
|
<function name="peek" />
|
||||||
|
</interface>
|
||||||
|
<script type="text/brightscript" uri="GroupStack.brs" />
|
||||||
|
</component>
|
219
source/Main.brs
219
source/Main.brs
|
@ -14,6 +14,7 @@ sub Main (args as dynamic) as void
|
||||||
m.screen.setMessagePort(m.port)
|
m.screen.setMessagePort(m.port)
|
||||||
m.scene = m.screen.CreateScene("JFScene")
|
m.scene = m.screen.CreateScene("JFScene")
|
||||||
m.screen.show()
|
m.screen.show()
|
||||||
|
m.overhang = m.scene.findNode("overhang")
|
||||||
|
|
||||||
' Set any initial Global Variables
|
' Set any initial Global Variables
|
||||||
m.global = m.screen.getGlobalNode()
|
m.global = m.screen.getGlobalNode()
|
||||||
|
@ -21,30 +22,27 @@ sub Main (args as dynamic) as void
|
||||||
playstateTask = CreateObject("roSGNode", "PlaystateTask")
|
playstateTask = CreateObject("roSGNode", "PlaystateTask")
|
||||||
playstateTask.id = "playstateTask"
|
playstateTask.id = "playstateTask"
|
||||||
|
|
||||||
m.global.addFields({ app_loaded: false, playstateTask: playstateTask })
|
groupStack = CreateObject("roSGNode", "GroupStack")
|
||||||
|
|
||||||
m.overhang = CreateObject("roSGNode", "JFOverhang")
|
m.global.addFields({ app_loaded: false, playstateTask: playstateTask, groupStack: groupStack })
|
||||||
m.scene.insertChild(m.overhang, 0)
|
|
||||||
|
|
||||||
app_start:
|
app_start:
|
||||||
m.overhang.title = ""
|
|
||||||
' First thing to do is validate the ability to use the API
|
' First thing to do is validate the ability to use the API
|
||||||
|
|
||||||
|
' TODO: Should eventually switch the loginflow over to using the pushGroup() code. It's
|
||||||
|
' safe to leave for now because wipe_groups() ensures the equivalent to an empty group
|
||||||
|
' stack.
|
||||||
if not LoginFlow() then return
|
if not LoginFlow() then return
|
||||||
wipe_groups()
|
wipe_groups()
|
||||||
|
|
||||||
' load home page
|
' load home page
|
||||||
m.overhang.title = tr("Home")
|
|
||||||
m.overhang.currentUser = m.user.Name
|
m.overhang.currentUser = m.user.Name
|
||||||
m.overhang.showOptions = true
|
|
||||||
group = CreateHomeGroup()
|
group = CreateHomeGroup()
|
||||||
group.userConfig = m.user.configuration
|
group.userConfig = m.user.configuration
|
||||||
group.callFunc("loadLibraries")
|
group.callFunc("loadLibraries")
|
||||||
m.scene.appendChild(group)
|
groupStack.callFunc("push", group)
|
||||||
|
|
||||||
m.scene.observeField("backPressed", m.port)
|
m.scene.observeField("exit", m.port)
|
||||||
m.scene.observeField("optionsPressed", m.port)
|
|
||||||
m.scene.observeField("mutePressed", m.port)
|
|
||||||
|
|
||||||
' Handle input messages
|
' Handle input messages
|
||||||
input = CreateObject("roInput")
|
input = CreateObject("roInput")
|
||||||
|
@ -53,20 +51,14 @@ sub Main (args as dynamic) as void
|
||||||
m.device = CreateObject("roDeviceInfo")
|
m.device = CreateObject("roDeviceInfo")
|
||||||
m.device.setMessagePort(m.port)
|
m.device.setMessagePort(m.port)
|
||||||
m.device.EnableScreensaverExitedEvent(true)
|
m.device.EnableScreensaverExitedEvent(true)
|
||||||
|
m.device.EnableAppFocusEvent(false)
|
||||||
|
|
||||||
' Check if we were sent content to play with the startup command (Deep Link)
|
' Check if we were sent content to play with the startup command (Deep Link)
|
||||||
if (args.mediaType <> invalid) and (args.contentId <> invalid)
|
if (args.mediaType <> invalid) and (args.contentId <> invalid)
|
||||||
video = CreateVideoPlayerGroup(args.contentId)
|
video = CreateVideoPlayerGroup(args.contentId)
|
||||||
|
|
||||||
if video <> invalid
|
if video <> invalid
|
||||||
if group.lastFocus = invalid then group.lastFocus = group.focusedChild
|
groupStack.callFunc("push", video)
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
group = video
|
|
||||||
m.scene.appendChild(group)
|
|
||||||
group.setFocus(true)
|
|
||||||
group.control = "play"
|
|
||||||
m.overhang.visible = false
|
|
||||||
else
|
else
|
||||||
dialog = createObject("roSGNode", "Dialog")
|
dialog = createObject("roSGNode", "Dialog")
|
||||||
dialog.id = "OKDialog"
|
dialog.id = "OKDialog"
|
||||||
|
@ -87,23 +79,10 @@ sub Main (args as dynamic) as void
|
||||||
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
|
||||||
print "CLOSING SCREEN"
|
print "CLOSING SCREEN"
|
||||||
return
|
return
|
||||||
|
else if isNodeEvent(msg, "exit")
|
||||||
else if isNodeEvent(msg, "backPressed")
|
return
|
||||||
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, "closeSidePanel")
|
else if isNodeEvent(msg, "closeSidePanel")
|
||||||
|
group = groupStack.callFunc("peek")
|
||||||
if group.lastFocus <> invalid
|
if group.lastFocus <> invalid
|
||||||
group.lastFocus.setFocus(true)
|
group.lastFocus.setFocus(true)
|
||||||
else
|
else
|
||||||
|
@ -116,67 +95,30 @@ sub Main (args as dynamic) as void
|
||||||
if itemNode.type = "Episode" or itemNode.type = "Movie" or itemNode.type = "Video"
|
if itemNode.type = "Episode" or itemNode.type = "Movie" or itemNode.type = "Video"
|
||||||
video = CreateVideoPlayerGroup(itemNode.id)
|
video = CreateVideoPlayerGroup(itemNode.id)
|
||||||
if video <> invalid
|
if video <> invalid
|
||||||
group.lastFocus = group.focusedChild
|
groupStack.callFunc("push", video)
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
group = video
|
|
||||||
m.scene.appendChild(group)
|
|
||||||
group.setFocus(true)
|
|
||||||
group.control = "play"
|
|
||||||
m.overhang.visible = false
|
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
else if isNodeEvent(msg, "selectedItem")
|
else if isNodeEvent(msg, "selectedItem")
|
||||||
' If you select a library from ANYWHERE, follow this flow
|
' If you select a library from ANYWHERE, follow this flow
|
||||||
selectedItem = msg.getData()
|
selectedItem = msg.getData()
|
||||||
if selectedItem.type = "CollectionFolder" or selectedItem.type = "UserView" or selectedItem.type = "Folder" or selectedItem.type = "Channel" or selectedItem.type = "Boxset"
|
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 = CreateItemGrid(selectedItem)
|
||||||
group.overhangTitle = selectedItem.title
|
groupStack.callFunc("push", group)
|
||||||
m.scene.appendChild(group)
|
|
||||||
else if selectedItem.type = "Episode"
|
else if selectedItem.type = "Episode"
|
||||||
' play episode
|
' play episode
|
||||||
' todo: create an episode page to link here
|
' todo: create an episode page to link here
|
||||||
video_id = selectedItem.id
|
video_id = selectedItem.id
|
||||||
m.scene.unobserveField("optionsPressed")
|
|
||||||
video = CreateVideoPlayerGroup(video_id)
|
video = CreateVideoPlayerGroup(video_id)
|
||||||
if video <> invalid
|
if video <> invalid
|
||||||
group.lastFocus = group.focusedChild
|
groupStack.callFunc("push", video)
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
group = video
|
|
||||||
m.scene.appendChild(group)
|
|
||||||
group.setFocus(true)
|
|
||||||
group.control = "play"
|
|
||||||
m.overhang.visible = false
|
|
||||||
end if
|
end if
|
||||||
else if selectedItem.type = "Series"
|
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 = CreateSeriesDetailsGroup(selectedItem.json)
|
||||||
group.overhangTitle = selectedItem.title
|
groupStack.callFunc("push", group)
|
||||||
m.scene.appendChild(group)
|
|
||||||
else if selectedItem.type = "Movie"
|
else if selectedItem.type = "Movie"
|
||||||
' open movie detail page
|
' 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 = CreateMovieDetailsGroup(selectedItem)
|
||||||
group.overhangTitle = selectedItem.title
|
groupStack.callFunc("push", group)
|
||||||
m.scene.appendChild(group)
|
|
||||||
|
|
||||||
else if selectedItem.type = "TvChannel" or selectedItem.type = "Video"
|
else if selectedItem.type = "TvChannel" or selectedItem.type = "Video"
|
||||||
' play channel feed
|
' play channel feed
|
||||||
video_id = selectedItem.id
|
video_id = selectedItem.id
|
||||||
|
@ -186,19 +128,11 @@ sub Main (args as dynamic) as void
|
||||||
dialog.title = tr("Loading Channel Data")
|
dialog.title = tr("Loading Channel Data")
|
||||||
m.scene.dialog = dialog
|
m.scene.dialog = dialog
|
||||||
|
|
||||||
m.scene.unobserveField("optionsPressed")
|
|
||||||
video = CreateVideoPlayerGroup(video_id)
|
video = CreateVideoPlayerGroup(video_id)
|
||||||
dialog.close = true
|
dialog.close = true
|
||||||
|
|
||||||
if video <> invalid
|
if video <> invalid
|
||||||
if group.lastFocus = invalid then group.lastFocus = group.focusedChild
|
groupStack.callFunc("push", video)
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
group = video
|
|
||||||
m.scene.appendChild(group)
|
|
||||||
group.setFocus(true)
|
|
||||||
group.control = "play"
|
|
||||||
m.overhang.visible = false
|
|
||||||
else
|
else
|
||||||
dialog = createObject("roSGNode", "Dialog")
|
dialog = createObject("roSGNode", "Dialog")
|
||||||
dialog.id = "OKDialog"
|
dialog.id = "OKDialog"
|
||||||
|
@ -215,62 +149,28 @@ sub Main (args as dynamic) as void
|
||||||
else if isNodeEvent(msg, "movieSelected")
|
else if isNodeEvent(msg, "movieSelected")
|
||||||
' If you select a movie from ANYWHERE, follow this flow
|
' If you select a movie from ANYWHERE, follow this flow
|
||||||
node = getMsgPicker(msg, "picker")
|
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 = CreateMovieDetailsGroup(node)
|
||||||
group.overhangTitle = node.title
|
groupStack.callFunc("push", group)
|
||||||
m.scene.appendChild(group)
|
|
||||||
else if isNodeEvent(msg, "seriesSelected")
|
else if isNodeEvent(msg, "seriesSelected")
|
||||||
' If you select a TV Series from ANYWHERE, follow this flow
|
' If you select a TV Series from ANYWHERE, follow this flow
|
||||||
node = getMsgPicker(msg, "picker")
|
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 = CreateSeriesDetailsGroup(node)
|
||||||
group.overhangTitle = node.title
|
groupStack.callFunc("push", group)
|
||||||
m.scene.appendChild(group)
|
|
||||||
else if isNodeEvent(msg, "seasonSelected")
|
else if isNodeEvent(msg, "seasonSelected")
|
||||||
' If you select a TV Season from ANYWHERE, follow this flow
|
' If you select a TV Season from ANYWHERE, follow this flow
|
||||||
ptr = msg.getData()
|
ptr = msg.getData()
|
||||||
' ptr is for [row, col] of selected item... but we only have 1 row
|
' ptr is for [row, col] of selected item... but we only have 1 row
|
||||||
series = msg.getRoSGNode()
|
series = msg.getRoSGNode()
|
||||||
node = series.seasonData.items[ptr[1]]
|
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)
|
group = CreateSeasonDetailsGroup(series.itemContent, node)
|
||||||
m.scene.appendChild(group)
|
groupStack.callFunc("push", group)
|
||||||
else if isNodeEvent(msg, "episodeSelected")
|
else if isNodeEvent(msg, "episodeSelected")
|
||||||
' If you select a TV Episode from ANYWHERE, follow this flow
|
' If you select a TV Episode from ANYWHERE, follow this flow
|
||||||
node = getMsgPicker(msg, "picker")
|
node = getMsgPicker(msg, "picker")
|
||||||
video_id = node.id
|
video_id = node.id
|
||||||
m.scene.unobserveField("optionsPressed")
|
|
||||||
video = CreateVideoPlayerGroup(video_id)
|
video = CreateVideoPlayerGroup(video_id)
|
||||||
if video <> invalid
|
if video <> invalid
|
||||||
group.lastFocus = group.focusedChild
|
groupStack.callFunc("push", video)
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
group = video
|
|
||||||
m.scene.appendChild(group)
|
|
||||||
group.setFocus(true)
|
|
||||||
group.control = "play"
|
|
||||||
m.overhang.visible = false
|
|
||||||
end if
|
end if
|
||||||
else if isNodeEvent(msg, "search_value")
|
else if isNodeEvent(msg, "search_value")
|
||||||
query = msg.getRoSGNode().search_value
|
query = msg.getRoSGNode().search_value
|
||||||
|
@ -289,10 +189,6 @@ sub Main (args as dynamic) as void
|
||||||
else if isNodeEvent(msg, "itemSelected")
|
else if isNodeEvent(msg, "itemSelected")
|
||||||
' Search item selected
|
' Search item selected
|
||||||
node = getMsgPicker(msg)
|
node = getMsgPicker(msg)
|
||||||
group.lastFocus = group.focusedChild
|
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
|
|
||||||
' TODO - swap this based on target.mediatype
|
' TODO - swap this based on target.mediatype
|
||||||
' types: [ Series (Show), Episode, Movie, Audio, Person, Studio, MusicArtist ]
|
' types: [ Series (Show), Episode, Movie, Audio, Person, Studio, MusicArtist ]
|
||||||
if node.type = "Series"
|
if node.type = "Series"
|
||||||
|
@ -300,9 +196,7 @@ sub Main (args as dynamic) as void
|
||||||
else
|
else
|
||||||
group = CreateMovieDetailsGroup(node)
|
group = CreateMovieDetailsGroup(node)
|
||||||
end if
|
end if
|
||||||
m.scene.appendChild(group)
|
groupStack.callFunc("push", group)
|
||||||
m.overhang.title = group.overhangTitle
|
|
||||||
|
|
||||||
else if isNodeEvent(msg, "buttonSelected")
|
else if isNodeEvent(msg, "buttonSelected")
|
||||||
' If a button is selected, we have some determining to do
|
' If a button is selected, we have some determining to do
|
||||||
btn = getButton(msg)
|
btn = getButton(msg)
|
||||||
|
@ -318,14 +212,7 @@ sub Main (args as dynamic) as void
|
||||||
video_id = group.id
|
video_id = group.id
|
||||||
video = CreateVideoPlayerGroup(video_id, audio_stream_idx)
|
video = CreateVideoPlayerGroup(video_id, audio_stream_idx)
|
||||||
if video <> invalid
|
if video <> invalid
|
||||||
group.lastFocus = group.focusedChild.focusedChild.focusedChild
|
groupStack.callFunc("push", video)
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
group = video
|
|
||||||
m.scene.appendChild(group)
|
|
||||||
group.setFocus(true)
|
|
||||||
group.control = "play"
|
|
||||||
m.overhang.visible = false
|
|
||||||
end if
|
end if
|
||||||
else if btn <> invalid and btn.id = "watched-button"
|
else if btn <> invalid and btn.id = "watched-button"
|
||||||
movie = group.itemContent
|
movie = group.itemContent
|
||||||
|
@ -361,14 +248,8 @@ sub Main (args as dynamic) as void
|
||||||
else
|
else
|
||||||
group.setFocus(true)
|
group.setFocus(true)
|
||||||
end if
|
end if
|
||||||
group.lastFocus = group.focusedChild
|
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
m.overhang.showOptions = false
|
|
||||||
m.scene.unobserveField("optionsPressed")
|
|
||||||
group = CreateSearchPage()
|
group = CreateSearchPage()
|
||||||
m.scene.appendChild(group)
|
groupStack.callFunc("push", group)
|
||||||
m.overhang.title = group.overhangTitle
|
|
||||||
group.findNode("SearchBox").findNode("search-input").setFocus(true)
|
group.findNode("SearchBox").findNode("search-input").setFocus(true)
|
||||||
group.findNode("SearchBox").findNode("search-input").active = true
|
group.findNode("SearchBox").findNode("search-input").active = true
|
||||||
else if button.id = "change_server"
|
else if button.id = "change_server"
|
||||||
|
@ -403,12 +284,11 @@ sub Main (args as dynamic) as void
|
||||||
else if isNodeEvent(msg, "state")
|
else if isNodeEvent(msg, "state")
|
||||||
node = msg.getRoSGNode()
|
node = msg.getRoSGNode()
|
||||||
if node.state = "finished"
|
if node.state = "finished"
|
||||||
stopPlayback()
|
node.control = "stop"
|
||||||
if node.showID = invalid
|
if node.showID = invalid
|
||||||
RemoveCurrentGroup()
|
groupStack.callFunc("pop")
|
||||||
else
|
else
|
||||||
nextEpisode = autoPlayNextEpisode(node.id, node.showID)
|
autoPlayNextEpisode(node.id, node.showID)
|
||||||
if nextEpisode <> invalid then group = nextEpisode
|
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
else if type(msg) = "roDeviceInfoEvent"
|
else if type(msg) = "roDeviceInfoEvent"
|
||||||
|
@ -431,14 +311,7 @@ sub Main (args as dynamic) as void
|
||||||
if info.DoesExist("mediatype") and info.DoesExist("contentid")
|
if info.DoesExist("mediatype") and info.DoesExist("contentid")
|
||||||
video = CreateVideoPlayerGroup(info.contentId)
|
video = CreateVideoPlayerGroup(info.contentId)
|
||||||
if video <> invalid
|
if video <> invalid
|
||||||
if group.lastFocus = invalid then group.lastFocus = group.focusedChild
|
groupStack.callFunc("push", video)
|
||||||
group.setFocus(false)
|
|
||||||
group.visible = false
|
|
||||||
group = video
|
|
||||||
m.scene.appendChild(group)
|
|
||||||
group.setFocus(true)
|
|
||||||
group.control = "play"
|
|
||||||
m.overhang.visible = false
|
|
||||||
else
|
else
|
||||||
dialog = createObject("roSGNode", "Dialog")
|
dialog = createObject("roSGNode", "Dialog")
|
||||||
dialog.id = "OKDialog"
|
dialog.id = "OKDialog"
|
||||||
|
@ -575,38 +448,6 @@ sub wipe_groups()
|
||||||
end while
|
end while
|
||||||
end sub
|
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
|
' Roku Performance monitoring
|
||||||
sub SendPerformanceBeacon(signalName as string)
|
sub SendPerformanceBeacon(signalName as string)
|
||||||
if m.global.app_loaded = false
|
if m.global.app_loaded = false
|
||||||
|
|
|
@ -174,6 +174,8 @@ end function
|
||||||
function CreateHomeGroup()
|
function CreateHomeGroup()
|
||||||
' Main screen after logging in. Shows the user's libraries
|
' Main screen after logging in. Shows the user's libraries
|
||||||
group = CreateObject("roSGNode", "Home")
|
group = CreateObject("roSGNode", "Home")
|
||||||
|
group.overhangTitle = tr("Home")
|
||||||
|
group.optionsAvailable = true
|
||||||
|
|
||||||
group.observeField("selectedItem", m.port)
|
group.observeField("selectedItem", m.port)
|
||||||
group.observeField("quickPlayNode", m.port)
|
group.observeField("quickPlayNode", m.port)
|
||||||
|
@ -230,6 +232,8 @@ end function
|
||||||
|
|
||||||
function CreateMovieDetailsGroup(movie)
|
function CreateMovieDetailsGroup(movie)
|
||||||
group = CreateObject("roSGNode", "MovieDetails")
|
group = CreateObject("roSGNode", "MovieDetails")
|
||||||
|
group.overhangTitle = movie.title
|
||||||
|
group.optionsAvailable = false
|
||||||
|
|
||||||
movie = ItemMetaData(movie.id)
|
movie = ItemMetaData(movie.id)
|
||||||
group.itemContent = movie
|
group.itemContent = movie
|
||||||
|
@ -244,6 +248,8 @@ end function
|
||||||
|
|
||||||
function CreateSeriesDetailsGroup(series)
|
function CreateSeriesDetailsGroup(series)
|
||||||
group = CreateObject("roSGNode", "TVShowDetails")
|
group = CreateObject("roSGNode", "TVShowDetails")
|
||||||
|
group.overhangTitle = series.title
|
||||||
|
group.optionsAvailable = false
|
||||||
|
|
||||||
group.itemContent = ItemMetaData(series.id)
|
group.itemContent = ItemMetaData(series.id)
|
||||||
group.seasonData = TVSeasons(series.id)
|
group.seasonData = TVSeasons(series.id)
|
||||||
|
@ -255,6 +261,8 @@ end function
|
||||||
|
|
||||||
function CreateSeasonDetailsGroup(series, season)
|
function CreateSeasonDetailsGroup(series, season)
|
||||||
group = CreateObject("roSGNode", "TVEpisodes")
|
group = CreateObject("roSGNode", "TVEpisodes")
|
||||||
|
group.overhangTitle = series.title + " " + season.title
|
||||||
|
group.optionsAvailable = false
|
||||||
|
|
||||||
group.seasonData = ItemMetaData(season.id).json
|
group.seasonData = ItemMetaData(season.id).json
|
||||||
group.objects = TVEpisodes(series.id, season.id)
|
group.objects = TVEpisodes(series.id, season.id)
|
||||||
|
@ -268,6 +276,8 @@ end function
|
||||||
function CreateItemGrid(libraryItem)
|
function CreateItemGrid(libraryItem)
|
||||||
group = CreateObject("roSGNode", "ItemGrid")
|
group = CreateObject("roSGNode", "ItemGrid")
|
||||||
group.parentItem = libraryItem
|
group.parentItem = libraryItem
|
||||||
|
group.overhangTitle = libraryItem.title
|
||||||
|
group.optionsAvailable = true
|
||||||
group.observeField("selectedItem", m.port)
|
group.observeField("selectedItem", m.port)
|
||||||
return group
|
return group
|
||||||
end function
|
end function
|
||||||
|
|
|
@ -208,13 +208,7 @@ function getAudioInfo(meta as object) as object
|
||||||
return results
|
return results
|
||||||
end function
|
end function
|
||||||
|
|
||||||
sub StopPlayback()
|
sub autoPlayNextEpisode(videoID as string, showID as string)
|
||||||
video = m.scene.focusedchild
|
|
||||||
video.control = "stop"
|
|
||||||
m.device.EnableAppFocusEvent(False)
|
|
||||||
end sub
|
|
||||||
|
|
||||||
function autoPlayNextEpisode(videoID as string, showID as string)
|
|
||||||
' use web client setting
|
' use web client setting
|
||||||
if m.user.Configuration.EnableNextEpisodeAutoPlay
|
if m.user.Configuration.EnableNextEpisodeAutoPlay
|
||||||
' query API for next episode ID
|
' 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
|
if data <> invalid and data.Items.Count() = 2
|
||||||
' remove finished video node
|
' remove finished video node
|
||||||
n = m.scene.getChildCount() - 1
|
m.global.groupStack.callFunc("pop")
|
||||||
m.scene.removeChildIndex(n)
|
|
||||||
' setup new video node
|
' setup new video node
|
||||||
nextVideo = CreateVideoPlayerGroup(data.Items[1].Id)
|
nextVideo = CreateVideoPlayerGroup(data.Items[1].Id)
|
||||||
m.scene.appendChild(nextVideo)
|
if nextVideo <> invalid
|
||||||
nextVideo.setFocus(true)
|
m.global.groupStack.callFunc("push", nextVideo)
|
||||||
nextVideo.control = "play"
|
else
|
||||||
return nextVideo
|
m.global.groupStack.callFunc("pop")
|
||||||
|
end if
|
||||||
else
|
else
|
||||||
' can't play next episode
|
' can't play next episode
|
||||||
RemoveCurrentGroup()
|
m.global.groupStack.callFunc("pop")
|
||||||
end if
|
end if
|
||||||
else
|
else
|
||||||
RemoveCurrentGroup()
|
m.global.groupStack.callFunc("pop")
|
||||||
end if
|
end if
|
||||||
return invalid
|
end sub
|
||||||
end function
|
|
||||||
|
|
14
source/utils/sceneManager.brs
Executable file
14
source/utils/sceneManager.brs
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
'
|
||||||
|
' Create a SceneManager instance to help manage application groups
|
||||||
|
function InitSceneManager(scene as object) as object
|
||||||
|
' Create a node object so data is passed by reference and to avoid
|
||||||
|
' having to re-save associative array in global variable.
|
||||||
|
groupStack = CreateObject("roSGNode", "GroupStack")
|
||||||
|
obj = {
|
||||||
|
groupStack: groupStack,
|
||||||
|
pushGroup: sub(group) : m.groupStack.callFunc("push", group) : end sub,
|
||||||
|
popGroup: sub() : m.groupStack.callFunc("pop") : end sub,
|
||||||
|
peekGroup: function() : return m.groupStack.callFunc("peek") : end function
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
end function
|
Loading…
Reference in New Issue
Block a user