* Refactor long press * Lint fix * Queue UI, refactor PlayQueue to use ContentNode * Add queue notification hint * Play at index * Play queue with highlight * Priority * Comment --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
143 lines
3.6 KiB
Plaintext
143 lines
3.6 KiB
Plaintext
import "pkg:/components/Dialog/DialogUtils.bs"
|
|
import "pkg:/components/Navigation/LongPress.bs"
|
|
import "pkg:/components/PlayQueue/PlayQueueViewUtils.bs"
|
|
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
|
import "pkg:/source/utils/FocusManagement.bs"
|
|
import "pkg:/source/utils/Logging.bs"
|
|
import "pkg:/source/utils/StringUtils.bs"
|
|
import "pkg:/source/utils/Types.bs"
|
|
|
|
function Init()
|
|
m.screens = {}
|
|
end function
|
|
|
|
function OnNodeReady()
|
|
InitializeLongPress(["options"])
|
|
NodeSetFocus(m.top.root, true)
|
|
end function
|
|
|
|
function PushScreen(node as object)
|
|
m.stack.appendChild(node)
|
|
FocusTopScreen(invalid)
|
|
end function
|
|
|
|
function PopScreen(unused as dynamic)
|
|
childCount = m.stack.getChildCount()
|
|
if childCount > 1
|
|
m.stack.removeChildIndex(childCount - 1)
|
|
FocusTopScreen(invalid)
|
|
end if
|
|
end function
|
|
|
|
function FocusTopScreen(unused as dynamic)
|
|
childCount = m.stack.getChildCount()
|
|
topScreen = m.stack.getChild(childCount - 1)
|
|
NodeSetFocus(topScreen, true)
|
|
end function
|
|
|
|
function HideRootScreen(screenName as string) as void
|
|
if StringUtils.IsNullOrEmpty(screenName)
|
|
return
|
|
end if
|
|
if not m.screens.DoesExist(screenName)
|
|
return
|
|
end if
|
|
screen = m.screens[screenName]
|
|
if screen = invalid
|
|
return
|
|
end if
|
|
screen.visible = false
|
|
end function
|
|
|
|
function ShowRootScreen(screenName as string) as void
|
|
if StringUtils.IsNullOrEmpty(screenName)
|
|
return
|
|
end if
|
|
if not m.screens.DoesExist(screenName)
|
|
screen = CreateObject("roSGNode", screenName)
|
|
screen.id = screenName
|
|
m.screens[screenName] = screen
|
|
' insert child at 0 to make sure it is behind the navbar
|
|
m.root.insertChild(screen, 0)
|
|
if screen.hasField("binding_done")
|
|
screen@.BindNode(invalid)
|
|
end if
|
|
end if
|
|
screen = m.screens[screenName]
|
|
if screen = invalid
|
|
return
|
|
end if
|
|
screen.visible = true
|
|
end function
|
|
|
|
function GetRootScreen(screenName as string) as object
|
|
if StringUtils.IsNullOrEmpty(screenName)
|
|
return invalid
|
|
end if
|
|
if not m.screens.DoesExist(screenName)
|
|
return invalid
|
|
end if
|
|
return m.screens[screenName]
|
|
end function
|
|
|
|
function onKeyEvent(key as string, press as boolean) as boolean
|
|
if LongPressHandler(key, press)
|
|
return true
|
|
end if
|
|
|
|
if key = OPTIONS_LONG_PRESS_KEY and press
|
|
LogInfo("Opening PlayQueueView")
|
|
PlayQueueViewUtils.Open(m.top.playQueue, m.top)
|
|
return true
|
|
end if
|
|
|
|
if key = "options" and not press
|
|
if VideoUtils.ToggleVideoPictureInPicture()
|
|
return true
|
|
end if
|
|
end if
|
|
|
|
if not press
|
|
return false
|
|
end if
|
|
|
|
if key = "play"
|
|
if VideoUtils.TogglePause()
|
|
return true
|
|
end if
|
|
end if
|
|
|
|
if key = "pause"
|
|
if VideoUtils.PauseVideo()
|
|
return true
|
|
end if
|
|
end if
|
|
|
|
if key = "playonly"
|
|
if VideoUtils.ResumeVideo()
|
|
return true
|
|
end if
|
|
end if
|
|
|
|
if key = "back"
|
|
if VideoUtils.IsVideoPlayerOpen() and not VideoUtils.IsVideoPlayerFullScreen()
|
|
if VideoUtils.ToggleVideoPictureInPicture()
|
|
return true
|
|
end if
|
|
end if
|
|
dialog = DialogUtils.ShowDialogButtons("Do you want to exit Playlet?", "Exit", ["Exit", "Cancel"])
|
|
dialog.observeField("buttonSelected", FuncName(OnExitDialog), ["buttonSelected"])
|
|
return true
|
|
end if
|
|
|
|
return false
|
|
end function
|
|
|
|
function OnExitDialog(event as object)
|
|
buttonIndex = event.GetData()
|
|
if buttonIndex = 0 ' Exit
|
|
LogInfo("Exiting app")
|
|
m.top.getScene().exitChannel = true
|
|
end if
|
|
end function
|