Skip to content

Commit

Permalink
Merge pull request #1376 from cewert/fix-quickplay
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert authored Oct 28, 2023
2 parents 213f325 + 22f4152 commit dd3972c
Show file tree
Hide file tree
Showing 25 changed files with 820 additions and 105 deletions.
19 changes: 16 additions & 3 deletions components/ItemGrid/ItemGrid.brs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ sub showTVGuide()
m.tvGuide.filter = m.filter
m.tvGuide.searchTerm = m.voiceBox.text
m.top.appendChild(m.tvGuide)
m.scheduleGrid = m.top.findNode("scheduleGrid")
m.tvGuide.lastFocus.setFocus(true)
end sub

Expand All @@ -742,6 +743,18 @@ sub onChannelFocused(msg)
m.channelFocused = node.focusedChannel
end sub

'Returns Focused Item
function getItemFocused()
if m.itemGrid.isinFocusChain() and isValid(m.itemGrid.itemFocused)
return m.itemGrid.content.getChild(m.itemGrid.itemFocused)
else if m.genreList.isinFocusChain() and isValid(m.genreList.rowItemFocused)
return m.genreList.content.getChild(m.genreList.rowItemFocused[0]).getChild(m.genreList.rowItemFocused[1])
else if m.scheduleGrid.isinFocusChain() and isValid(m.scheduleGrid.itemFocused)
return m.scheduleGrid.content.getChild(m.scheduleGrid.itemFocused)
end if
return invalid
end function

function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false

Expand Down Expand Up @@ -788,11 +801,11 @@ function onKeyEvent(key as string, press as boolean) as boolean
m.loadItemsTask.control = "stop"
return true
end if
else if key = "play" or key = "OK"
else if key = "play"
markupGrid = m.top.findNode("itemGrid")
itemToPlay = markupGrid.content.getChild(markupGrid.itemFocused)
itemToPlay = getItemFocused()

if itemToPlay <> invalid and (itemToPlay.type = "Movie" or itemToPlay.type = "Episode")
if itemToPlay <> invalid
m.top.quickPlayNode = itemToPlay
return true
else if itemToPlay <> invalid and itemToPlay.type = "Photo"
Expand Down
12 changes: 8 additions & 4 deletions components/ItemGrid/MovieLibraryView.brs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,12 @@ end sub
'
'Returns Focused Item
function getItemFocused()
return m.itemGrid.content.getChild(m.itemGrid.itemFocused)
if m.itemGrid.isinFocusChain() and isValid(m.itemGrid.itemFocused)
return m.itemGrid.content.getChild(m.itemGrid.itemFocused)
else if m.genreList.isinFocusChain() and isValid(m.genreList.rowItemFocused)
return m.genreList.content.getChild(m.genreList.rowItemFocused[0]).getChild(m.genreList.rowItemFocused[1])
end if
return invalid
end function

'
Expand Down Expand Up @@ -870,11 +875,10 @@ function onKeyEvent(key as string, press as boolean) as boolean
m.loadItemsTask.control = "stop"
return true
end if
else if key = "play" or key = "OK"

else if key = "play"
itemToPlay = getItemFocused()

if itemToPlay <> invalid and (itemToPlay.type = "Movie" or itemToPlay.type = "Episode")
if itemToPlay <> invalid
m.top.quickPlayNode = itemToPlay
return true
end if
Expand Down
16 changes: 12 additions & 4 deletions components/ItemGrid/MusicLibraryView.brs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,12 @@ end sub
'
'Returns Focused Item
function getItemFocused()
return m.itemGrid.content.getChild(m.itemGrid.itemFocused)
if m.itemGrid.isinFocusChain() and isValid(m.itemGrid.itemFocused)
return m.itemGrid.content.getChild(m.itemGrid.itemFocused)
else if m.genreList.isinFocusChain() and isValid(m.genreList.itemFocused)
return m.genreList.content.getChild(m.genreList.itemFocused)
end if
return invalid
end function

'
Expand Down Expand Up @@ -751,7 +756,6 @@ function onKeyEvent(key as string, press as boolean) as boolean
alpha.setFocus(true)
return true
end if

else if key = "right" and m.Alpha.isinFocusChain()
m.top.alphaActive = false
m.Alpha.setFocus(false)
Expand All @@ -761,21 +765,25 @@ function onKeyEvent(key as string, press as boolean) as boolean
m.genreList.setFocus(m.genreList.opacity = 1)

return true

else if key = "replay" and m.itemGrid.isinFocusChain()
if m.resetGrid = true
m.itemGrid.animateToItem = 0
else
m.itemGrid.jumpToItem = 0
end if

else if key = "replay" and m.genreList.isinFocusChain()
if m.resetGrid = true
m.genreList.animateToItem = 0
else
m.genreList.jumpToItem = 0
end if
return true
else if key = "play"
itemToPlay = getItemFocused()
if itemToPlay <> invalid
m.top.quickPlayNode = itemToPlay
return true
end if
end if

if key = "replay"
Expand Down
31 changes: 2 additions & 29 deletions components/data/HomeData.brs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sub setData()
m.top.iconUrl = "pkg:/images/media_type_icons/folder_white.png"
end if

else if datum.type = "Episode"
else if datum.type = "Episode" or datum.type = "MusicVideo"
m.top.isWatched = datum.UserData.Played

imgParams = {}
Expand Down Expand Up @@ -72,32 +72,7 @@ sub setData()
m.top.widePosterUrl = ImageURL(datum.Id, "Backdrop", imgParams)
end if

else if datum.type = "Movie"
m.top.isWatched = datum.UserData.Played

imgParams = {}
imgParams.Append({ "maxHeight": 261 })
imgParams.Append({ "maxWidth": 175 })

if datum.ImageTags.Primary <> invalid
param = { "Tag": datum.ImageTags.Primary }
imgParams.Append(param)
end if

m.top.posterURL = ImageURL(datum.id, "Primary", imgParams)

' For wide image, use backdrop
imgParams["maxWidth"] = 464

if datum.ImageTags <> invalid and datum.imageTags.Thumb <> invalid
imgParams["Tag"] = datum.imageTags.Thumb
m.top.thumbnailUrl = ImageURL(datum.Id, "Thumb", imgParams)
else if datum.BackdropImageTags[0] <> invalid
imgParams["Tag"] = datum.BackdropImageTags[0]
m.top.thumbnailUrl = ImageURL(datum.id, "Backdrop", imgParams)
end if

else if datum.type = "Video"
else if datum.type = "Movie" or datum.type = "Video"
m.top.isWatched = datum.UserData.Played

imgParams = {}
Expand Down Expand Up @@ -126,12 +101,10 @@ sub setData()
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL
m.top.posterUrl = m.top.thumbnailURL

else if datum.type = "TvChannel" or datum.type = "Channel"
params = { "Tag": datum.ImageTags.Primary, "maxHeight": 261, "maxWidth": 464 }
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL
m.top.iconUrl = "pkg:/images/media_type_icons/live_tv_white.png"
end if

end sub
5 changes: 5 additions & 0 deletions components/extras/ExtrasRowList.brs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sub init()
updateSize()
m.top.rowFocusAnimationStyle = "fixedFocus"
m.top.observeField("rowItemSelected", "onRowItemSelected")
m.top.observeField("rowItemFocused", "onRowItemFocused")

' Set up all Tasks
m.LoadPeopleTask = CreateObject("roSGNode", "LoadItemsTask")
Expand Down Expand Up @@ -207,3 +208,7 @@ end sub
sub onRowItemSelected()
m.top.selectedItem = m.top.content.getChild(m.top.rowItemSelected[0]).getChild(m.top.rowItemSelected[1])
end sub

sub onRowItemFocused()
m.top.focusedItem = m.top.content.getChild(m.top.rowItemFocused[0]).getChild(m.top.rowItemFocused[1])
end sub
1 change: 1 addition & 0 deletions components/extras/ExtrasRowList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<interface>
<field id="type" type="string" />
<field id="parentId" type="string" />
<field id="focusedItem" type="node" alwaysNotify="true" />
<field id="selectedItem" type="node" alwaysNotify="true" />
<function name="loadParts" />
<function name="loadPersonVideos" />
Expand Down
3 changes: 2 additions & 1 deletion components/home/HomeItem.brs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ end sub
sub itemContentChanged()
itemData = m.top.itemContent
if itemData = invalid then return

itemData.Title = itemData.name ' Temporarily required while we move from "HomeItem" to "JFContentItem"

m.itemPoster.width = itemData.imageWidth
Expand Down Expand Up @@ -135,7 +136,7 @@ sub itemContentChanged()
return
end if

if itemData.type = "Movie"
if itemData.type = "Movie" or itemData.type = "MusicVideo"
m.itemText.text = itemData.name

if itemData.PlayedPercentage > 0
Expand Down
13 changes: 6 additions & 7 deletions components/home/HomeRows.brs
Original file line number Diff line number Diff line change
Expand Up @@ -522,21 +522,20 @@ sub itemSelected()
end sub

function onKeyEvent(key as string, press as boolean) as boolean
handled = false
if press
if key = "play"
print "play was pressed from homerow"
itemToPlay = m.top.content.getChild(m.top.rowItemFocused[0]).getChild(m.top.rowItemFocused[1])
if isValid(itemToPlay) and (itemToPlay.type = "Movie" or itemToPlay.type = "Episode")
if isValid(itemToPlay)
m.top.quickPlayNode = itemToPlay
end if
handled = true
end if

if key = "replay"
return true
else if key = "replay"
m.top.jumpToRowItem = [m.top.rowItemFocused[0], 0]
return true
end if
end if
return handled
return false
end function

function filterNodeArray(nodeArray as object, nodeKey as string, excludeArray as object) as object
Expand Down
2 changes: 1 addition & 1 deletion components/home/HomeRows.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<component name="HomeRows" extends="RowList">
<interface>
<field id="selectedItem" type="node" alwaysNotify="true" />
<field id="quickPlayNode" type="node" alwaysNotify="true" />
<field id="quickPlayNode" type="node" />
<function name="updateHomeRows" />
<function name="loadLibraries" />
</interface>
Expand Down
3 changes: 2 additions & 1 deletion components/home/LoadItemsTask.brs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ sub loadItems()
if isValid(data) and isValid(data.Items)
for each item in data.Items
' Skip Books for now as we don't support it (issue #558)
if item.Type <> "Book"
' also skip songs since there is limited space
if not (item.Type = "Book" or item.Type = "Audio")
tmp = CreateObject("roSGNode", "HomeData")

params = {}
Expand Down
45 changes: 31 additions & 14 deletions components/manager/QueueManager.brs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sub init()
m.queue = []
m.originalQueue = []
m.queueTypes = []
m.isPlaying = false
' Preroll videos only play if user has cinema mode setting enabled
m.isPrerollActive = m.global.session.user.settings["playback.cinemamode"]
m.position = 0
Expand All @@ -19,6 +20,7 @@ end sub

' Clear all content from play queue
sub clear()
m.isPlaying = false
m.queue = []
m.queueTypes = []
m.isPrerollActive = m.global.session.user.settings["playback.cinemamode"]
Expand Down Expand Up @@ -111,6 +113,7 @@ end function

' Play items in queue
sub playQueue()
m.isPlaying = true
nextItem = getCurrentItem()
if not isValid(nextItem) then return

Expand All @@ -122,11 +125,21 @@ sub playQueue()
return
end if

if nextItemMediaType = "musicvideo"
CreateVideoPlayerView()
return
end if

if nextItemMediaType = "video"
CreateVideoPlayerView()
return
end if

if nextItemMediaType = "movie"
CreateVideoPlayerView()
return
end if

if nextItemMediaType = "episode"
CreateVideoPlayerView()
return
Expand Down Expand Up @@ -196,21 +209,25 @@ end function
sub shuffleQueueItems()
' By calling getQueue 2 different ways, Roku avoids needing to do a deep copy
m.originalQueue = m.global.queueManager.callFunc("getQueue")
songIDArray = getQueue()

' Move the currently playing song to the front of the queue
temp = top()
songIDArray[0] = getCurrentItem()
songIDArray[getPosition()] = temp

for i = 1 to songIDArray.count() - 1
j = Rnd(songIDArray.count() - 1)
temp = songIDArray[i]
songIDArray[i] = songIDArray[j]
songIDArray[j] = temp
end for
itemIDArray = getQueue()
temp = invalid

if m.isPlaying
' Save the currently playing item
temp = getCurrentItem()
' remove currently playing item from itemIDArray
itemIDArray.Delete(m.position)
end if

' shuffle all items
itemIDArray = shuffleArray(itemIDArray)

if m.isPlaying
' Put currently playing item in front of itemIDArray
itemIDArray.Unshift(temp)
end if

set(songIDArray)
set(itemIDArray)
end sub

' Return the fitst item in the play queue
Expand Down
6 changes: 6 additions & 0 deletions components/movies/MovieDetails.brs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ function onKeyEvent(key as string, press as boolean) as boolean
audioOptionsClosed()
return true
end if
else if key = "play" and m.extrasGrid.hasFocus()
print "Play was pressed from the movie details extras slider"
if m.extrasGrid.focusedItem <> invalid
m.top.quickPlayNode = m.extrasGrid.focusedItem
return true
end if
end if
return false
end function
1 change: 1 addition & 0 deletions components/movies/MovieDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@
<field id="trailerAvailable" type="bool" onChange="trailerAvailableChanged" value="false" />
<field id="selectedAudioStreamIndex" type="integer" />
<field id="selectedVideoStreamId" type="string" />
<field id="quickPlayNode" type="node" alwaysNotify="true" />
</interface>
</component>
16 changes: 16 additions & 0 deletions components/music/ArtistView.brs
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,21 @@ function onKeyEvent(key as string, press as boolean) as boolean
end if
end if

if key = "play"
print "play button pressed from ArtistView"
itemToPlay = invalid

if isValid(m.albums) and m.albums.isInFocusChain()
itemToPlay = m.albums.MusicArtistAlbumData.items[m.albums.itemFocused]
else if isValid(m.appearsOn) and m.appearsOn.isInFocusChain()
itemToPlay = m.appearsOn.MusicArtistAlbumData.items[m.appearsOn.itemFocused]
end if

if isValid(itemToPlay)
m.top.quickPlayNode = itemToPlay
return true
end if
end if

return false
end function
Loading

0 comments on commit dd3972c

Please sign in to comment.