diff --git a/components/tvshows/TVEpisodes.bs b/components/tvshows/TVEpisodes.bs index 583e4d30b..ffc225cdc 100644 --- a/components/tvshows/TVEpisodes.bs +++ b/components/tvshows/TVEpisodes.bs @@ -46,10 +46,28 @@ sub updateSeason() m.top.overhangTitle = m.top.seasonData.SeriesName + " - " + m.top.seasonData.name end sub +' get the currently focused item +function getFocusedItem() as dynamic + if not isValid(m.top.focusedChild) or not isValid(m.top.focusedChild.focusedChild) + return invalid + end if + + focusedChild = m.top.focusedChild.focusedChild + if not isValid(focusedChild.content) then return invalid + m.top.lastFocus = focusedChild + + if isValidAndNotEmpty(focusedChild.rowItemFocused) + itemToPlay = focusedChild.content.getChild(focusedChild.rowItemFocused[0]).getChild(0) + if isValid(itemToPlay) and isValidAndNotEmpty(itemToPlay.id) + return itemToPlay + end if + end if + + return invalid +end function + ' Handle navigation input from the remote and act on it function onKeyEvent(key as string, press as boolean) as boolean - handled = false - if key = "left" and m.tvEpisodeRow.hasFocus() m.shuffle.setFocus(true) return true @@ -70,7 +88,15 @@ function onKeyEvent(key as string, press as boolean) as boolean return true end if - if key = "OK" or key = "play" + if key = "OK" + if m.tvEpisodeRow.isInFocusChain() + focusedItem = getFocusedItem() + if isValid(focusedItem) + m.top.selectedItem = focusedItem + end if + return true + end if + if m.shuffle.hasFocus() episodeList = m.rows.getChild(0).objects.items @@ -97,22 +123,13 @@ function onKeyEvent(key as string, press as boolean) as boolean end if end if - focusedChild = m.top.focusedChild.focusedChild - if focusedChild.content = invalid then return handled - - ' OK needs to be handled on release... - proceed = false - if key = "OK" - proceed = true - end if - - if press and key = "play" or proceed = true - m.top.lastFocus = focusedChild - itemToPlay = focusedChild.content.getChild(focusedChild.rowItemFocused[0]).getChild(0) - if isValid(itemToPlay) and isValid(itemToPlay.id) and itemToPlay.id <> "" - m.top.quickPlayNode = itemToPlay + if key = "play" + focusedItem = getFocusedItem() + if isValid(focusedItem) + m.top.quickPlayNode = focusedItem end if - handled = true + return true end if - return handled + + return false end function diff --git a/components/tvshows/TVEpisodes.xml b/components/tvshows/TVEpisodes.xml index 06af1fe94..b9b437b66 100644 --- a/components/tvshows/TVEpisodes.xml +++ b/components/tvshows/TVEpisodes.xml @@ -12,6 +12,7 @@ + diff --git a/source/ShowScenes.bs b/source/ShowScenes.bs index dca7b2b28..4f301b7c9 100644 --- a/source/ShowScenes.bs +++ b/source/ShowScenes.bs @@ -790,7 +790,7 @@ function CreateSeasonDetailsGroup(series as object, season as object) as dynamic group.extrasObjects = TVSeasonExtras(season.id) ' watch for button presses - group.observeField("episodeSelected", m.port) + group.observeField("selectedItem", m.port) group.observeField("quickPlayNode", m.port) ' finished building SeasonDetails view stopLoadingSpinner()