add quickplay support for photos, photoalbums, and photo libraries

This commit is contained in:
Charles Ewert 2023-11-14 11:57:00 -05:00
parent d51620c982
commit eedb277409
4 changed files with 82 additions and 10 deletions

View File

@ -95,6 +95,11 @@ sub OnScreenHidden()
m.statusTimer.control = "stop"
end sub
' isSlideshow component field has changed
sub isSlideshowChanged()
m.slideshow = m.top.isSlideshow
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false

View File

@ -21,6 +21,7 @@
<interface>
<field id="itemsNode" type="node" />
<field id="itemsArray" type="roArray" />
<field id="isSlideshow" type="bool" onChange="isSlideshowChanged" />
<field id="itemIndex" type="integer" value="-1" onChange="itemContentChanged" />
</interface>
</component>

View File

@ -201,6 +201,10 @@ sub Main (args as dynamic) as void
quickplay.tvChannel(itemNode)
else if itemType = "program"
quickplay.program(itemNode)
else if itemType = "photo"
quickplay.photo(itemNode)
else if itemType = "photoalbum"
quickplay.photoAlbum(itemNode)
end if
m.global.queueManager.callFunc("playQueue")
@ -298,25 +302,23 @@ sub Main (args as dynamic) as void
print "a photo was selected from the home screen"
print "selectedItem=", selectedItem
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.itemsNode = selectedItem
photoPlayer.itemIndex = 0
m.global.sceneManager.callfunc("pushScene", photoPlayer)
quickplay.photo(selectedItem)
end if
else if selectedItemType = "PhotoAlbum"
print "a photo album was selected"
print "selectedItem=", selectedItem
' grab all photos inside photo album
photoData = api.users.GetItemsByQuery(m.global.session.user.id, {
photoAlbumData = api.users.GetItemsByQuery(m.global.session.user.id, {
"parentId": selectedItem.id,
"includeItemTypes": "Photo",
"Recursive": true
})
print "photoData=", photoData
print "photoAlbumData=", photoAlbumData
if isValid(photoData) and isValidAndNotEmpty(photoData.items)
if isValid(photoAlbumData) and isValidAndNotEmpty(photoAlbumData.items)
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.itemsArray = photoData.items
photoPlayer.itemsArray = photoAlbumData.items
photoPlayer.itemIndex = 0
m.global.sceneManager.callfunc("pushScene", photoPlayer)
end if

View File

@ -54,6 +54,38 @@ namespace quickplay
m.global.queueManager.callFunc("push", itemNode)
end sub
' A single photo.
sub photo(itemNode as object)
if not isValid(itemNode) or not isValid(itemNode.id) then return
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.itemsNode = itemNode
photoPlayer.itemIndex = 0
m.global.sceneManager.callfunc("pushScene", photoPlayer)
end sub
' A photo album.
sub photoAlbum(itemNode as object)
if not isValid(itemNode) or not isValid(itemNode.id) then return
' grab all photos inside photo album
photoAlbumData = api.users.GetItemsByQuery(m.global.session.user.id, {
"parentId": itemNode.id,
"includeItemTypes": "Photo",
"sortBy": "Random",
"Recursive": true
})
print "photoAlbumData=", photoAlbumData
if isValid(photoAlbumData) and isValidAndNotEmpty(photoAlbumData.items)
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.isSlideshow = true
photoPlayer.itemsArray = photoAlbumData.items
photoPlayer.itemIndex = 0
m.global.sceneManager.callfunc("pushScene", photoPlayer)
end if
end sub
' A music album.
' Play the entire album starting with track 1.
sub album(itemNode as object)
@ -370,6 +402,7 @@ namespace quickplay
}
' modify api query based on folder type
folderType = Lcase(itemNode.json.type)
print "folderType=", folderType
if folderType = "studio"
paramArray["studioIds"] = itemNode.id
else if folderType = "genre"
@ -381,6 +414,11 @@ namespace quickplay
paramArray["genreIds"] = itemNode.id
paramArray.delete("videoTypes")
paramArray["includeItemTypes"] = "Audio"
else if folderType = "photoalbum"
paramArray["parentId"] = itemNode.id
paramArray["includeItemTypes"] = "Photo"
paramArray.delete("videoTypes")
paramArray.delete("Recursive")
else
paramArray["parentId"] = itemNode.id
end if
@ -401,7 +439,15 @@ namespace quickplay
quickplay.multipleSeries(folderData.items)
end if
else
quickplay.pushToQueue(folderData.items, true)
if folderType = "photoalbum"
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.isSlideshow = true
photoPlayer.itemsArray = folderData.items
photoPlayer.itemIndex = 0
m.global.sceneManager.callfunc("pushScene", photoPlayer)
else
quickplay.pushToQueue(folderData.items, true)
end if
end if
end if
end sub
@ -515,7 +561,25 @@ namespace quickplay
if isValid(data) and isValidAndNotEmpty(data.items)
quickplay.pushToQueue(data.Items)
end if
' else if collectionType = "homevideos" ' also used for a "Photo" library
else if collectionType = "homevideos"
' Photo library - items can be type video, photo, or photoAlbum
' grab all photos inside photo album
folderData = api.users.GetItemsByQuery(m.global.session.user.id, {
"parentId": itemNode.id,
"includeItemTypes": "Photo",
"sortBy": "Random",
"Recursive": true
})
print "folderData=", folderData
if isValid(folderData) and isValidAndNotEmpty(folderData.items)
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.isSlideshow = true
photoPlayer.itemsArray = folderData.items
photoPlayer.itemIndex = 0
m.global.sceneManager.callfunc("pushScene", photoPlayer)
end if
else
print "Quick Play WARNING: Unknown collection type"
end if