Skip to content

Commit

Permalink
Merge pull request #1513 from cewert/fix-playback-episode-list
Browse files Browse the repository at this point in the history
Fix episode list bug where OK was triggering quickplay
  • Loading branch information
1hitsong authored Nov 20, 2023
2 parents 3f2c48d + 491ef43 commit 67f2e21
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
55 changes: 36 additions & 19 deletions components/tvshows/TVEpisodes.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
1 change: 1 addition & 0 deletions components/tvshows/TVEpisodes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</children>
<interface>
<field id="episodeSelected" alias="picker.itemSelected" />
<field id="selectedItem" type="node" alwaysNotify="true" />
<field id="quickPlayNode" type="node" />
<field id="seasonData" type="assocarray" onChange="setSeasonLoading" />
<field id="objects" alias="picker.objects" />
Expand Down
2 changes: 1 addition & 1 deletion source/ShowScenes.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 67f2e21

Please sign in to comment.