Fix video selection bug (#419)

* Fix video selection bug

* Refactor key handling

* comment
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2024-07-04 11:16:09 -04:00
1 parent 896d0b9bf3
commit ebc5d81180
28 files changed
+214 -158

No files matched your search

+6
View File
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- A bug where a the right video will not play if selected too quickly
## [0.24.5] - 2024-07-03 ## [0.24.5] - 2024-07-03
- Additional Spanish (Mexico) translations (Thanks to Jean Carton) - Additional Spanish (Mexico) translations (Thanks to Jean Carton)
@@ -5,6 +5,7 @@ import "pkg:/components/VideoQueue/VideoQueueViewUtils.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -86,18 +87,18 @@ function GetRootScreen(screenName as string) as object
return m.screens[screenName] return m.screens[screenName]
end function end function
function onKeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if LongPressHandler(key, press) if LongPressHandler(key, press)
return true return true
end if end if
if key = OPTIONS_LONG_PRESS_KEY and press if key = RemoteKeys.OptionsLongPress and press
LogInfo("Opening VideoQueueView") LogInfo("Opening VideoQueueView")
VideoQueueViewUtils.Open(m.top.videoQueue, m.top) VideoQueueViewUtils.Open(m.top.videoQueue, m.top)
return true return true
end if end if
if key = "options" and not press if key = RemoteKeys.Options and not press
if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue) if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue)
return true return true
end if end if
@@ -107,25 +108,25 @@ function onKeyEvent(key as string, press as boolean) as boolean
return false return false
end if end if
if key = "play" if key = RemoteKeys.Play
if VideoQueueUtils.TogglePause(m.top.videoQueue) if VideoQueueUtils.TogglePause(m.top.videoQueue)
return true return true
end if end if
end if end if
if key = "pause" if key = RemoteKeys.Pause
if VideoQueueUtils.Pause(m.top.videoQueue) if VideoQueueUtils.Pause(m.top.videoQueue)
return true return true
end if end if
end if end if
if key = "playonly" if key = RemoteKeys.PlayOnly
if VideoQueueUtils.Play(m.top.videoQueue) if VideoQueueUtils.Play(m.top.videoQueue)
return true return true
end if end if
end if end if
if key = "back" if key = RemoteKeys.Back
if VideoQueueUtils.IsVideoPlayerOpen(m.top.videoQueue) and not VideoQueueUtils.IsVideoPlayerFullScreen(m.top.videoQueue) if VideoQueueUtils.IsVideoPlayerOpen(m.top.videoQueue) and not VideoQueueUtils.IsVideoPlayerFullScreen(m.top.videoQueue)
if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue) if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue)
return true return true
@@ -1,4 +1,5 @@
import "pkg:/source/utils/MathUtils.bs" import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -129,12 +130,12 @@ function OnButtonFocused()
end if end if
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if not press if not press
return false return false
end if end if
if key = "OK" if key = RemoteKeys.Ok
disabled = m.top.disabled disabled = m.top.disabled
if not disabled if not disabled
m.top.buttonSelected = true m.top.buttonSelected = true
@@ -7,6 +7,7 @@ import "pkg:/source/utils/DisposableObserve.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -36,8 +37,8 @@ end function
function OnNodeready() function OnNodeready()
m.rowList@.BindNode() m.rowList@.BindNode()
SetNavigation(m.rowList, "up", m.subscribeButton) SetNavigation(m.rowList, RemoteKeys.Up, m.subscribeButton)
SetNavigation(m.subscribeButton, "down", m.rowList) SetNavigation(m.subscribeButton, RemoteKeys.Down, m.rowList)
m.subscribeButton.text = Tr(Locale.Buttons.Subscribe) m.subscribeButton.text = Tr(Locale.Buttons.Subscribe)
DisposableObserveFieldScoped(m.subscribeButton, "buttonSelected", FuncName(OnSubscribeButtonSelected)) DisposableObserveFieldScoped(m.subscribeButton, "buttonSelected", FuncName(OnSubscribeButtonSelected))
@@ -104,7 +105,7 @@ function CreateChannelFeeds(authorId as string, author as string, tabs as object
return feeds return feeds
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
@@ -113,7 +114,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
return false return false
end if end if
if key = "back" if key = RemoteKeys.Back
Close() Close()
return true return true
end if end if
@@ -1,5 +1,6 @@
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -152,22 +153,22 @@ function OnItemSelected(event as object) as void
end if end if
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if press = false if press = false
return false return false
end if end if
if key = "back" if key = RemoteKeys.Back
Close() Close()
return true return true
end if end if
if key = "up" if key = RemoteKeys.Up
m.optionsList.jumpToItem = m.optionsList.content.getChildCount() - 1 m.optionsList.jumpToItem = m.optionsList.content.getChildCount() - 1
return true return true
end if end if
if key = "down" if key = RemoteKeys.Down
m.optionsList.jumpToItem = 0 m.optionsList.jumpToItem = 0
return true return true
end if end if
@@ -67,7 +67,7 @@ function OnDialogClosed()
CancelTimer() CancelTimer()
end function end function
function onKeyEvent(_key as string, _press as boolean) as boolean function OnKeyEvent(_key as string, _press as boolean) as boolean
if m.timer = invalid if m.timer = invalid
return false return false
end if end if
+3 -2
View File
@@ -1,4 +1,5 @@
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -116,8 +117,8 @@ function UnfocusItem(index as integer) as void
m.appController@.HideRootScreen(item.screen) m.appController@.HideRootScreen(item.screen)
end function end function
function onKeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if key <> "right" or not press if key <> RemoteKeys.Right or not press
return false return false
end if end if
@@ -1,11 +1,10 @@
const OK_LONG_PRESS_KEY = "OK_LONG_PRESS" import "pkg:/source/utils/RemoteKeys.bs"
const OPTIONS_LONG_PRESS_KEY = "OPTIONS_LONG_PRESS"
function InitializeLongPress(keys as object, duration = 1.0 as float) function InitializeLongPress(keys as object, duration = 1.0 as float)
longPressKeyMap = { longPressKeyMap = {}
"OK": OK_LONG_PRESS_KEY longPressKeyMap[RemoteKeys.Ok] = RemoteKeys.OkLongPress
"options": OPTIONS_LONG_PRESS_KEY longPressKeyMap[RemoteKeys.Options] = RemoteKeys.OptionsLongPress
}
m._longPressKeyMap = {} m._longPressKeyMap = {}
for each key in keys for each key in keys
m._longPressKeyMap[key] = longPressKeyMap[key] m._longPressKeyMap[key] = longPressKeyMap[key]
@@ -16,10 +15,9 @@ function InitializeLongPress(keys as object, duration = 1.0 as float)
' Using the keyboard: ' Using the keyboard:
' - press K to simulate an "OK" long press on the remote. ' - press K to simulate an "OK" long press on the remote.
' - press O to simulate an "options" long press on the remote. ' - press O to simulate an "options" long press on the remote.
simulatedLongPressKeyMap = { simulatedLongPressKeyMap = {}
"OK": "Lit_k" simulatedLongPressKeyMap[RemoteKeys.Ok] = "Lit_k"
"options": "Lit_o" simulatedLongPressKeyMap[RemoteKeys.Options] = "Lit_o"
}
m._simulatedLongPressKeyMap = {} m._simulatedLongPressKeyMap = {}
for each key in keys for each key in keys
@@ -43,7 +41,7 @@ function LongPressHandler(key as string, press as boolean) as boolean
LogInfo(`[${subtype}] Simulating`, simulatedKey, "long press using key:", key, "press:", press) LogInfo(`[${subtype}] Simulating`, simulatedKey, "long press using key:", key, "press:", press)
longPressKey = m._longPressKeyMap[simulatedKey] longPressKey = m._longPressKeyMap[simulatedKey]
m._longPressFired = true m._longPressFired = true
return OnkeyEvent(longPressKey, press) return OnKeyEvent(longPressKey, press)
end if end if
#end if #end if
@@ -87,5 +85,5 @@ function LongPressTimerFired() as void
return return
end if end if
OnkeyEvent(m._longPressKeyMap[m._longPressKey], true) OnKeyEvent(m._longPressKeyMap[m._longPressKey], true)
end function end function
@@ -8,6 +8,7 @@ import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/ErrorUtils.bs" import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -61,17 +62,17 @@ function OnContentSet() as void
LoadPlaylistIfNeeded() LoadPlaylistIfNeeded()
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if LongPressHandler(key, press) if LongPressHandler(key, press)
return true return true
end if end if
if key = OK_LONG_PRESS_KEY and press if key = RemoteKeys.OkLongPress and press
OnItemLongPressed(m.list.itemFocused) OnItemLongPressed(m.list.itemFocused)
return true return true
end if end if
if key = "OK" and not press if key = RemoteKeys.Ok and not press
OnItemSelected(m.list.itemFocused) OnItemSelected(m.list.itemFocused)
return true return true
end if end if
@@ -80,7 +81,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
return false return false
end if end if
if key = "back" if key = RemoteKeys.Back
Close() Close()
return true return true
end if end if
@@ -2,6 +2,7 @@ import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/DisposableObserve.bs" import "pkg:/source/utils/DisposableObserve.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -16,10 +17,10 @@ function Init()
end function end function
function OnNodeReady() function OnNodeReady()
SetNavigation(m.activateButton, "down", m.logoutButton) SetNavigation(m.activateButton, RemoteKeys.Down, m.logoutButton)
SetNavigation(m.logoutButton, "down", m.closeButton) SetNavigation(m.logoutButton, RemoteKeys.Down, m.closeButton)
SetNavigation(m.closeButton, "up", m.logoutButton) SetNavigation(m.closeButton, RemoteKeys.Up, m.logoutButton)
SetNavigation(m.logoutButton, "up", m.activateButton) SetNavigation(m.logoutButton, RemoteKeys.Up, m.activateButton)
DisposableObserveFieldScoped(m.profilesService, "currentProfile", FuncName(OnCunrrentProfileChanged)) DisposableObserveFieldScoped(m.profilesService, "currentProfile", FuncName(OnCunrrentProfileChanged))
DisposableObserveFieldScoped(m.profilesService, "onProfileLogout", FuncName(OnProfileLogout)) DisposableObserveFieldScoped(m.profilesService, "onProfileLogout", FuncName(OnProfileLogout))
@@ -57,17 +58,17 @@ function OnFocusChange() as void
end if end if
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
if key = "options" or key = "play" or key = "pause" or key = "playonly" if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play ' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
return false return false
end if end if
if key = "back" and press if key = RemoteKeys.Back and press
Close() Close()
return true return true
end if end if
@@ -3,6 +3,7 @@ import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/Services/BookmarksService/BookmarksServiceUtils.bs" import "pkg:/components/Services/BookmarksService/BookmarksServiceUtils.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -16,8 +17,8 @@ function Init()
end function end function
function OnNodeReady() function OnNodeReady()
SetNavigation(invalid, "back", m.navBar) SetNavigation(invalid, RemoteKeys.Back, m.navBar)
SetNavigation(invalid, "left", m.navBar) SetNavigation(invalid, RemoteKeys.Left, m.navBar)
m.rowList@.BindNode() m.rowList@.BindNode()
@@ -73,7 +74,7 @@ function SetRowListContent(bookmarksContent as object)
m.rowList.feeds = BookmarksServiceUtils.BookmarksContentToFeed(bookmarksContent) m.rowList.feeds = BookmarksServiceUtils.BookmarksContentToFeed(bookmarksContent)
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
@@ -3,6 +3,7 @@ import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/RemoteKeys.bs"
function Init() function Init()
m.top.focusable = true m.top.focusable = true
@@ -12,8 +13,8 @@ function Init()
end function end function
function OnNodeReady() function OnNodeReady()
SetNavigation(invalid, "back", m.navBar) SetNavigation(invalid, RemoteKeys.Back, m.navBar)
SetNavigation(invalid, "left", m.navBar) SetNavigation(invalid, RemoteKeys.Left, m.navBar)
m.rowList@.BindNode() m.rowList@.BindNode()
@@ -34,7 +35,7 @@ function OnFocusChange() as void
NodeSetFocus(m.rowList, true) NodeSetFocus(m.rowList, true)
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
@@ -2,6 +2,7 @@ import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/ProfileView/ProfileViewUtils.bs" import "pkg:/components/ProfileView/ProfileViewUtils.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -10,8 +11,8 @@ function Init()
end function end function
function OnNodeReady() function OnNodeReady()
SetNavigation(invalid, "back", m.navBar) SetNavigation(invalid, RemoteKeys.Back, m.navBar)
SetNavigation(invalid, "left", m.navBar) SetNavigation(invalid, RemoteKeys.Left, m.navBar)
m.profileRowList.content = m.profilesService.content m.profileRowList.content = m.profilesService.content
m.profileRowList.observeFieldScoped("rowItemSelected", FuncName(OnRowItemSelected)) m.profileRowList.observeFieldScoped("rowItemSelected", FuncName(OnRowItemSelected))
@@ -25,7 +26,7 @@ function OnFocusChange() as void
NodeSetFocus(m.profileRowList, true) NodeSetFocus(m.profileRowList, true)
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
@@ -7,6 +7,7 @@ import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/MathUtils.bs" import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
function Init() function Init()
@@ -39,13 +40,13 @@ function Init()
end function end function
function OnNodeReady() function OnNodeReady()
SetNavigation(m.webAppButton, "down", m.linkWithWifiButton) SetNavigation(m.webAppButton, RemoteKeys.Down, m.linkWithWifiButton)
SetNavigation(m.linkWithWifiButton, "down", m.linkWithTvButton) SetNavigation(m.linkWithWifiButton, RemoteKeys.Down, m.linkWithTvButton)
SetNavigation(m.linkWithTvButton, "up", m.linkWithWifiButton) SetNavigation(m.linkWithTvButton, RemoteKeys.Up, m.linkWithWifiButton)
SetNavigation(m.linkWithWifiButton, "up", m.webAppButton) SetNavigation(m.linkWithWifiButton, RemoteKeys.Up, m.webAppButton)
SetNavigation(invalid, "back", m.navBar) SetNavigation(invalid, RemoteKeys.Back, m.navBar)
SetNavigation(invalid, "left", m.navBar) SetNavigation(invalid, RemoteKeys.Left, m.navBar)
address = m.webserver@.GetServerAddress() address = m.webserver@.GetServerAddress()
isValidAddress = not StringUtils.IsNullOrEmpty(address) isValidAddress = not StringUtils.IsNullOrEmpty(address)
@@ -102,7 +103,7 @@ function OnButtonSizeChange()
m.linkWithTvButton.minWidth = width m.linkWithTvButton.minWidth = width
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
navigation = NavigationKeyHandler(key, press) navigation = NavigationKeyHandler(key, press)
if navigation.handled if navigation.handled
ShowTab(navigation.node) ShowTab(navigation.node)
@@ -1,6 +1,7 @@
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/ArrayUtils.bs" import "pkg:/source/utils/ArrayUtils.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -127,10 +128,10 @@ function Init()
navigationNodes = [m.controls.date, m.controls.type, m.controls.duration, m.controls.features, m.controls.sort] navigationNodes = [m.controls.date, m.controls.type, m.controls.duration, m.controls.features, m.controls.sort]
for i = 0 to navigationNodes.count() - 2 for i = 0 to navigationNodes.count() - 2
SetNavigation(navigationNodes[i], "right", navigationNodes[i + 1]) SetNavigation(navigationNodes[i], RemoteKeys.Right, navigationNodes[i + 1])
end for end for
for i = 1 to navigationNodes.count() - 1 for i = 1 to navigationNodes.count() - 1
SetNavigation(navigationNodes[i], "left", navigationNodes[i - 1]) SetNavigation(navigationNodes[i], RemoteKeys.Left, navigationNodes[i - 1])
end for end for
end function end function
@@ -243,19 +244,19 @@ function SetFilterArray(control as object) as void
m.searchScreen.filters = state m.searchScreen.filters = state
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
navigation = NavigationKeyHandler(key, press) navigation = NavigationKeyHandler(key, press)
if navigation.handled if navigation.handled
m.currentNavigtionNode = navigation.node m.currentNavigtionNode = navigation.node
return true return true
end if end if
if key = "options" or key = "play" or key = "pause" or key = "playonly" if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play ' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
return false return false
end if end if
if key = "back" and press if key = RemoteKeys.Back and press
Close() Close()
return true return true
end if end if
@@ -9,6 +9,7 @@ import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/LoadingScreen.bs" import "pkg:/source/utils/LoadingScreen.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/UrlUtils.bs" import "pkg:/source/utils/UrlUtils.bs"
function Init() function Init()
@@ -50,30 +51,30 @@ function OnNodeReady()
m.top.ObserveField("visible", FuncName(OnVisibilityChange)) m.top.ObserveField("visible", FuncName(OnVisibilityChange))
m.rowlist.ObserveFieldScoped("onError", FuncName(OnSearchError)) m.rowlist.ObserveFieldScoped("onError", FuncName(OnSearchError))
SetNavigation(invalid, "back", m.navBar, function() SetNavigation(invalid, RemoteKeys.Back, m.navBar, function()
ScrollUp() ScrollUp()
end function) end function)
SetNavigation(m.suggestions, "right", m.keyboard) SetNavigation(m.suggestions, RemoteKeys.Right, m.keyboard)
SetNavigation(m.filtersButton, "right", m.keyboard) SetNavigation(m.filtersButton, RemoteKeys.Right, m.keyboard)
SetNavigation(m.keyboard, "left", m.suggestions) SetNavigation(m.keyboard, RemoteKeys.Left, m.suggestions)
SetNavigation(m.suggestions, "left", m.navBar) SetNavigation(m.suggestions, RemoteKeys.Left, m.navBar)
SetNavigation(m.filtersButton, "left", m.navBar) SetNavigation(m.filtersButton, RemoteKeys.Left, m.navBar)
SetNavigation(m.keyboard, "left", m.navBar) SetNavigation(m.keyboard, RemoteKeys.Left, m.navBar)
SetNavigation(m.rowList, "left", m.navBar, function() SetNavigation(m.rowList, RemoteKeys.Left, m.navBar, function()
ScrollUp() ScrollUp()
end function) end function)
SetNavigation(m.filtersButton, "down", m.suggestions) SetNavigation(m.filtersButton, RemoteKeys.Down, m.suggestions)
SetNavigation(m.filtersButton, "down", m.keyboard) SetNavigation(m.filtersButton, RemoteKeys.Down, m.keyboard)
SetNavigation(invalid, "down", m.rowList, function() SetNavigation(invalid, RemoteKeys.Down, m.rowList, function()
ScrollDown() ScrollDown()
end function) end function)
SetNavigation(m.rowList, "up", m.suggestions, function() SetNavigation(m.rowList, RemoteKeys.Up, m.suggestions, function()
ScrollUp() ScrollUp()
end function) end function)
SetNavigation(m.suggestions, "up", m.filtersButton) SetNavigation(m.suggestions, RemoteKeys.Up, m.filtersButton)
SetNavigation(m.keyboard, "up", m.filtersButton) SetNavigation(m.keyboard, RemoteKeys.Up, m.filtersButton)
m.currentNavigtionNode = m.suggestions m.currentNavigtionNode = m.suggestions
' Trigger suggestions ' Trigger suggestions
@@ -310,7 +311,7 @@ function ScrollDown() as void
m.scrollAnimation.control = "start" m.scrollAnimation.control = "start"
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
navigation = NavigationKeyHandler(key, press) navigation = NavigationKeyHandler(key, press)
if navigation.handled if navigation.handled
m.currentNavigtionNode = navigation.node m.currentNavigtionNode = navigation.node
@@ -2,6 +2,7 @@ import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs" import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/MathUtils.bs" import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -17,17 +18,17 @@ function Init()
m.closeButton = m.top.findNode("closeButton") m.closeButton = m.top.findNode("closeButton")
m.saveButton = m.top.findNode("saveButton") m.saveButton = m.top.findNode("saveButton")
SetNavigation(m.checkList, "down", m.saveButton) SetNavigation(m.checkList, RemoteKeys.Down, m.saveButton)
SetNavigation(m.saveButton, "up", m.checkList) SetNavigation(m.saveButton, RemoteKeys.Up, m.checkList)
SetNavigation(m.closeButton, "up", m.checkList) SetNavigation(m.closeButton, RemoteKeys.Up, m.checkList)
SetNavigation(m.saveButton, "right", m.closeButton) SetNavigation(m.saveButton, RemoteKeys.Right, m.closeButton)
SetNavigation(m.closeButton, "left", m.saveButton) SetNavigation(m.closeButton, RemoteKeys.Left, m.saveButton)
SetNavigation(m.moveUpButton, "left", m.checkList) SetNavigation(m.moveUpButton, RemoteKeys.Left, m.checkList)
SetNavigation(m.moveDownButton, "left", m.checkList) SetNavigation(m.moveDownButton, RemoteKeys.Left, m.checkList)
SetNavigation(m.checkList, "right", m.moveUpButton) SetNavigation(m.checkList, RemoteKeys.Right, m.moveUpButton)
SetNavigation(m.moveUpButton, "down", m.moveDownButton) SetNavigation(m.moveUpButton, RemoteKeys.Down, m.moveDownButton)
SetNavigation(m.moveDownButton, "up", m.moveUpButton) SetNavigation(m.moveDownButton, RemoteKeys.Up, m.moveUpButton)
SetNavigation(m.moveDownButton, "down", m.closeButton) SetNavigation(m.moveDownButton, RemoteKeys.Down, m.closeButton)
m.moveUpButton.observeField("buttonSelected", FuncName(OnMoveUpButtonSelected)) m.moveUpButton.observeField("buttonSelected", FuncName(OnMoveUpButtonSelected))
m.moveDownButton.observeField("buttonSelected", FuncName(OnMoveDownButtonSelected)) m.moveDownButton.observeField("buttonSelected", FuncName(OnMoveDownButtonSelected))
@@ -55,17 +56,17 @@ function OnFocusChange() as void
NodeSetFocus(m.checkList, true) NodeSetFocus(m.checkList, true)
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
if key = "options" or key = "play" or key = "pause" or key = "playonly" if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play ' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
return false return false
end if end if
if key = "back" and press if key = RemoteKeys.Back and press
Close() Close()
return true return true
end if end if
@@ -2,6 +2,7 @@ import "pkg:/components/Dialog/DialogPalette.bs"
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs" import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs" import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -17,19 +18,19 @@ function Init()
m.testButton.observeField("buttonSelected", FuncName(OnTestButtonSelected)) m.testButton.observeField("buttonSelected", FuncName(OnTestButtonSelected))
m.publicInstances.observeField("instance", FuncName(OnPublicInstanceSelected)) m.publicInstances.observeField("instance", FuncName(OnPublicInstanceSelected))
SetNavigation(m.editButton, "down", m.publicInstances) SetNavigation(m.editButton, RemoteKeys.Down, m.publicInstances)
SetNavigation(m.editButton, "down", m.testButton) SetNavigation(m.editButton, RemoteKeys.Down, m.testButton)
SetNavigation(m.publicInstances, "up", m.editButton) SetNavigation(m.publicInstances, RemoteKeys.Up, m.editButton)
SetNavigation(m.publicInstances, "down", m.testButton) SetNavigation(m.publicInstances, RemoteKeys.Down, m.testButton)
SetNavigation(m.testButton, "up", m.publicInstances) SetNavigation(m.testButton, RemoteKeys.Up, m.publicInstances)
SetNavigation(m.testButton, "up", m.editButton) SetNavigation(m.testButton, RemoteKeys.Up, m.editButton)
SetNavigation(m.saveButton, "up", m.publicInstances) SetNavigation(m.saveButton, RemoteKeys.Up, m.publicInstances)
SetNavigation(m.saveButton, "up", m.editButton) SetNavigation(m.saveButton, RemoteKeys.Up, m.editButton)
SetNavigation(m.saveButton, "left", m.testButton) SetNavigation(m.saveButton, RemoteKeys.Left, m.testButton)
SetNavigation(m.testButton, "right", m.saveButton) SetNavigation(m.testButton, RemoteKeys.Right, m.saveButton)
m.currentNavigtionNode = m.editButton m.currentNavigtionNode = m.editButton
m.textEditBox.hintText = `e.g. ${Invidious.DEFAULT_INSTANCE}` m.textEditBox.hintText = `e.g. ${Invidious.DEFAULT_INSTANCE}`
@@ -65,19 +66,19 @@ function OnFocusChange() as void
NodeSetFocus(m.currentNavigtionNode, true) NodeSetFocus(m.currentNavigtionNode, true)
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
navigation = NavigationKeyHandler(key, press) navigation = NavigationKeyHandler(key, press)
if navigation.handled if navigation.handled
m.currentNavigtionNode = navigation.node m.currentNavigtionNode = navigation.node
return true return true
end if end if
if key = "options" or key = "play" or key = "pause" or key = "playonly" if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play ' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
return false return false
end if end if
if key = "back" and press if key = RemoteKeys.Back and press
Close() Close()
return true return true
end if end if
@@ -4,6 +4,7 @@ import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/AsyncTask/AsyncTask.bs" import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs" import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -14,8 +15,8 @@ function Init()
m.closeButton.observeField("buttonSelected", FuncName(Close)) m.closeButton.observeField("buttonSelected", FuncName(Close))
m.testList.observeField("itemSelected", FuncName(ShowTestDetails)) m.testList.observeField("itemSelected", FuncName(ShowTestDetails))
SetNavigation(m.closeButton, "up", m.testList) SetNavigation(m.closeButton, RemoteKeys.Up, m.testList)
SetNavigation(m.testList, "down", m.closeButton) SetNavigation(m.testList, RemoteKeys.Down, m.closeButton)
end function end function
function OnFocusChange() as void function OnFocusChange() as void
@@ -26,17 +27,17 @@ function OnFocusChange() as void
NodeSetFocus(m.closeButton, true) NodeSetFocus(m.closeButton, true)
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
if key = "options" or key = "play" or key = "pause" or key = "playonly" if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play ' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
return false return false
end if end if
if key = "back" and press if key = RemoteKeys.Back and press
Close() Close()
return true return true
end if end if
@@ -1,6 +1,7 @@
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/MathUtils.bs" import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -14,10 +15,10 @@ function Init()
m.minusButton.observeFieldScoped("buttonSelected", FuncName(OnMinusSelected)) m.minusButton.observeFieldScoped("buttonSelected", FuncName(OnMinusSelected))
m.plusButton.observeFieldScoped("buttonSelected", FuncName(OnPlusSelected)) m.plusButton.observeFieldScoped("buttonSelected", FuncName(OnPlusSelected))
SetNavigation(m.minusButton, "right", m.numberButton) SetNavigation(m.minusButton, RemoteKeys.Right, m.numberButton)
SetNavigation(m.numberButton, "left", m.minusButton) SetNavigation(m.numberButton, RemoteKeys.Left, m.minusButton)
SetNavigation(m.numberButton, "right", m.plusButton) SetNavigation(m.numberButton, RemoteKeys.Right, m.plusButton)
SetNavigation(m.plusButton, "left", m.numberButton) SetNavigation(m.plusButton, RemoteKeys.Left, m.numberButton)
end function end function
function BindPreference(preferences as object, key as string) function BindPreference(preferences as object, key as string)
@@ -55,7 +56,7 @@ function OnFocusChange() as void
NodeSetFocus(m.numberButton, true) NodeSetFocus(m.numberButton, true)
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
@@ -1,6 +1,7 @@
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/Navigation/ScrollTo.bs" import "pkg:/components/Navigation/ScrollTo.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -36,22 +37,22 @@ function OnNodeReady()
m.currentNavigtionNode = m.firstCategory m.currentNavigtionNode = m.firstCategory
end if end if
if previousCategory <> invalid if previousCategory <> invalid
SetNavigation(previousCategory.node, "down", category.node) SetNavigation(previousCategory.node, RemoteKeys.Down, category.node)
SetNavigation(category.node, "up", previousCategory.node) SetNavigation(category.node, RemoteKeys.Up, previousCategory.node)
end if end if
controls = CreateControls(item, container, startX + controlsX, startY, controlSpacing) controls = CreateControls(item, container, startX + controlsX, startY, controlSpacing)
if controls <> invalid if controls <> invalid
if controls.nodes.Count() > 0 if controls.nodes.Count() > 0
SetNavigation(category.node, "right", controls.nodes[0]) SetNavigation(category.node, RemoteKeys.Right, controls.nodes[0])
end if end if
for each control in controls.nodes for each control in controls.nodes
SetNavigation(control, "left", category.node) SetNavigation(control, RemoteKeys.Left, category.node)
if previousControl <> invalid if previousControl <> invalid
SetNavigation(previousControl, "down", control) SetNavigation(previousControl, RemoteKeys.Down, control)
SetNavigation(control, "up", previousControl) SetNavigation(control, RemoteKeys.Up, previousControl)
end if end if
previousControl = control previousControl = control
@@ -66,8 +67,8 @@ function OnNodeReady()
previousCategory = category previousCategory = category
end for end for
SetNavigation(invalid, "back", m.navBar) SetNavigation(invalid, RemoteKeys.Back, m.navBar)
SetNavigation(invalid, "left", m.navBar) SetNavigation(invalid, RemoteKeys.Left, m.navBar)
end function end function
function CreateCategoryNode(item as object, container as object, startX as integer, startY as integer) as object function CreateCategoryNode(item as object, container as object, startX as integer, startY as integer) as object
@@ -197,7 +198,7 @@ function CreateRokuComponent(item as object, container as object) as object
return node return node
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
navigation = NavigationKeyHandler(key, press) navigation = NavigationKeyHandler(key, press)
if navigation.handled if navigation.handled
m.currentNavigtionNode = navigation.node m.currentNavigtionNode = navigation.node
@@ -9,6 +9,7 @@ import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/DisposableObserve.bs" import "pkg:/source/utils/DisposableObserve.bs"
import "pkg:/source/utils/ErrorUtils.bs" import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
' TODO:P1 add the option to remove a row if it does not have any content ' TODO:P1 add the option to remove a row if it does not have any content
@@ -20,6 +21,7 @@ end function
function OnNodeReady() function OnNodeReady()
DisposableObserveField(m.top, "itemFocused", FuncName(OnItemFocused)) DisposableObserveField(m.top, "itemFocused", FuncName(OnItemFocused))
DisposableObserveField(m.top, "rowItemFocused", FuncName(OnRowItemFocused)) DisposableObserveField(m.top, "rowItemFocused", FuncName(OnRowItemFocused))
DisposableObserveField(m.top, "rowItemSelected", FuncName(OnRealRowItemSelected))
DisposableObserveField(m.top, "focusedChild", FuncName(OnFocusedChildChange)) DisposableObserveField(m.top, "focusedChild", FuncName(OnFocusedChildChange))
DisposableObserveField(m.top, "visible", FuncName(OnVisibilityChange)) DisposableObserveField(m.top, "visible", FuncName(OnVisibilityChange))
@@ -317,20 +319,28 @@ function OnVideoRowListRowContentTaskResult(output as object) as void
LoadRowsIfNeeded() LoadRowsIfNeeded()
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnRealRowItemSelected()
' This is the event that fires when m.top.rowItemSelected changes
LongPressHandler(RemoteKeys.Ok, true)
end function
function OnKeyEvent(key as string, press as boolean) as boolean
' This OnKeyEvent should not handle OK/true, because that will block rowItemSelected from firing
' Do not pass OK/true to LongPressHandler, since we did that in OnRealRowItemSelected
if not (key = RemoteKeys.Ok and press)
if LongPressHandler(key, press) if LongPressHandler(key, press)
return true return true
end if end if
end if
if key = OK_LONG_PRESS_KEY and press if key = RemoteKeys.OkLongPress and press
OnRowItemLongPressed(m.top.rowItemFocused) OnRowItemLongPressed(m.top.rowItemFocused)
return true return true
end if end if
if key = "OK" and not press if key = RemoteKeys.Ok and not press
' TODO:P1: rowItemFocused doesn't update fast enough. If direction then Ok are pressed quickly, the wrong item is selected ' item was selected, but was not a long press, this is a request to open the video/channel/playlist
' Use currFocusColumn OnRowItemSelected(m.top.rowItemSelected)
OnRowItemSelected(m.top.rowItemFocused)
return true return true
end if end if
return false return false
@@ -8,6 +8,7 @@ import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs" import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/ErrorUtils.bs" import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
function Init() function Init()
SetPlayerStyle() SetPlayerStyle()
@@ -420,29 +421,29 @@ function HandleOKPress() as boolean
return handled return handled
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if press = false if press = false
return false return false
end if end if
' Unfortunately, a Video node cannot capture the "options" key (because, Roku...) ' Unfortunately, a Video node cannot capture the "options" key (because, Roku...)
' https://community.roku.com/t5/Roku-Developer-Program/Bug-in-10-0-1-Options-key-is-not-being-consumed-by-onKeyEvent-when-Video-node-is-in-focus/m-p/709200/highlight/true#M49312 ' https://community.roku.com/t5/Roku-Developer-Program/Bug-in-10-0-1-Options-key-is-not-being-consumed-by-onKeyEvent-when-Video-node-is-in-focus/m-p/709200/highlight/true#M49312
' Because of that, the button "down" is used to shrink the video for picture in picture mode ' Because of that, the button "down" is used to shrink the video for picture in picture mode
if key = "down" if key = RemoteKeys.Down
if VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue) if VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue)
return true return true
end if end if
end if end if
if key = "back" if key = RemoteKeys.Back
m.videoQueue.closePlayer = true m.videoQueue.closePlayer = true
return true return true
end if end if
if key = "OK" if key = RemoteKeys.Ok
return HandleOKPress() return HandleOKPress()
end if end if
if key = "left" or key = "right" or key = "rewind" or key = "fastforward" if key = RemoteKeys.Left or key = RemoteKeys.Right or key = RemoteKeys.Rewind or key = RemoteKeys.FastForward
' We're paused and one of the buttons is pressed: left, right ff, rw. ' We're paused and one of the buttons is pressed: left, right ff, rw.
' That means we're seeking position. Check that in HandleOKPress and exit early ' That means we're seeking position. Check that in HandleOKPress and exit early
m.isSeekingPosition = true m.isSeekingPosition = true
@@ -1,3 +1,4 @@
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -41,12 +42,12 @@ function OnDisabledChange()
m.top.focusable = not disabled m.top.focusable = not disabled
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if not press if not press
return false return false
end if end if
if key = "OK" if key = RemoteKeys.Ok
disabled = m.top.disabled disabled = m.top.disabled
if not disabled if not disabled
m.top.buttonSelected = true m.top.buttonSelected = true
@@ -6,6 +6,7 @@ import "pkg:/source/utils/DisposableObserve.bs"
import "pkg:/source/utils/ErrorUtils.bs" import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -52,15 +53,15 @@ function OnNodeReady()
DisposableObserveField(m.progressTimer, "fire", FuncName(OnProgress)) DisposableObserveField(m.progressTimer, "fire", FuncName(OnProgress))
DisposableObserveField(m.hideVideoUiTimer, "fire", FuncName(OnHideVideoUiTimer)) DisposableObserveField(m.hideVideoUiTimer, "fire", FuncName(OnHideVideoUiTimer))
SetNavigation(m.previousButton, "right", m.playButton) SetNavigation(m.previousButton, RemoteKeys.Right, m.playButton)
SetNavigation(m.playButton, "right", m.nextButton) SetNavigation(m.playButton, RemoteKeys.Right, m.nextButton)
SetNavigation(m.nextButton, "right", m.minimizeButton) SetNavigation(m.nextButton, RemoteKeys.Right, m.minimizeButton)
SetNavigation(m.playButton, "right", m.minimizeButton) SetNavigation(m.playButton, RemoteKeys.Right, m.minimizeButton)
SetNavigation(m.minimizeButton, "left", m.nextButton) SetNavigation(m.minimizeButton, RemoteKeys.Left, m.nextButton)
SetNavigation(m.minimizeButton, "left", m.playButton) SetNavigation(m.minimizeButton, RemoteKeys.Left, m.playButton)
SetNavigation(m.nextButton, "left", m.playButton) SetNavigation(m.nextButton, RemoteKeys.Left, m.playButton)
SetNavigation(m.playButton, "left", m.previousButton) SetNavigation(m.playButton, RemoteKeys.Left, m.previousButton)
if m.top.hasFocus() and m.videoUi.visible and m.videoUi.opacity = 1 if m.top.hasFocus() and m.videoUi.visible and m.videoUi.opacity = 1
NodeSetFocus(m.playButton, true) NodeSetFocus(m.playButton, true)
@@ -145,7 +146,7 @@ function OnClose()
m.top.dispose = true m.top.dispose = true
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
m.hideVideoUiTimer.control = "stop" m.hideVideoUiTimer.control = "stop"
m.hideVideoUiTimer.control = "start" m.hideVideoUiTimer.control = "start"
if ShowVideoUi() if ShowVideoUi()
@@ -160,7 +161,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
return false return false
end if end if
if key = "back" if key = RemoteKeys.Back
m.videoQueue.closePlayer = true m.videoQueue.closePlayer = true
return true return true
end if end if
@@ -5,6 +5,7 @@ import "pkg:/source/utils/DisposableObserve.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -16,8 +17,8 @@ function Init()
DisposableObserveField(m.clearButton, "buttonSelected", FuncName(OnClearButtonSelected)) DisposableObserveField(m.clearButton, "buttonSelected", FuncName(OnClearButtonSelected))
DisposableObserveField(m.queueList, "itemSelected", FuncName(OnItemSelected)) DisposableObserveField(m.queueList, "itemSelected", FuncName(OnItemSelected))
SetNavigation(m.queueList, "up", m.clearButton) SetNavigation(m.queueList, RemoteKeys.Up, m.clearButton)
SetNavigation(m.clearButton, "down", m.queueList) SetNavigation(m.clearButton, RemoteKeys.Down, m.queueList)
m.videosDetailsToLoad = [] m.videosDetailsToLoad = []
end function end function
@@ -57,7 +58,7 @@ function OnContentSet() as void
LoadVideoDetailsIfNeeded() LoadVideoDetailsIfNeeded()
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled if NavigationKeyHandler(key, press).handled
return true return true
end if end if
@@ -66,7 +67,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
return false return false
end if end if
if key = "back" if key = RemoteKeys.Back
Close() Close()
return true return true
end if end if
@@ -16,9 +16,9 @@ namespace Tests
node1 = CreateObject("roSGNode", "Node") node1 = CreateObject("roSGNode", "Node")
node2 = CreateObject("roSGNode", "Node") node2 = CreateObject("roSGNode", "Node")
m.top@.SetNavigation(node1, "right", node2) m.top@.SetNavigation(node1, RemoteKeys.Right, node2)
m.assertAAHasKey(m.node._navigation, "right") m.assertAAHasKey(m.node._navigation, RemoteKeys.Right)
end function end function
@it("navigates to the right node") @it("navigates to the right node")
@@ -26,12 +26,12 @@ namespace Tests
node1 = CreateObject("roSGNode", "Node") node1 = CreateObject("roSGNode", "Node")
node2 = CreateObject("roSGNode", "Node") node2 = CreateObject("roSGNode", "Node")
m.top@.SetNavigation(node1, "right", node2) m.top@.SetNavigation(node1, RemoteKeys.Right, node2)
NodeSetFocus(node1, true) NodeSetFocus(node1, true)
node2.focusable = true node2.focusable = true
m.top@.NavigationKeyHandler("right", true) m.top@.NavigationKeyHandler(RemoteKeys.Right, true)
m.assertFalse(node1.hasFocus()) m.assertFalse(node1.hasFocus())
m.assertTrue(node2.hasFocus()) m.assertTrue(node2.hasFocus())
@@ -41,11 +41,11 @@ namespace Tests
function _() function _()
node2 = CreateObject("roSGNode", "Node") node2 = CreateObject("roSGNode", "Node")
m.top@.SetNavigation(invalid, "right", node2) m.top@.SetNavigation(invalid, RemoteKeys.Right, node2)
node2.focusable = true node2.focusable = true
m.top@.NavigationKeyHandler("right", true) m.top@.NavigationKeyHandler(RemoteKeys.Right, true)
m.assertTrue(node2.hasFocus()) m.assertTrue(node2.hasFocus())
end function end function
@@ -0,0 +1,20 @@
' https://developer.roku.com/en-ca/docs/references/scenegraph/component-functions/onkeyevent.md
enum RemoteKeys
Back = "back"
Up = "up"
Down = "down"
Left = "left"
Right = "right"
Ok = "OK"
Replay = "replay"
Play = "play"
PlayOnly = "playonly"
Rewind = "rewind"
FastForward = "fastforward"
Options = "options"
Pause = "pause"
' Long press keys - these are not standard, and used to handle long press events
OkLongPress = "OK_LONG_PRESS"
OptionsLongPress = "OPTIONS_LONG_PRESS"
end enum