Skip to content

Commit

Permalink
Update API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jellyfin-bot committed Nov 15, 2023
1 parent 6c759bc commit c99ec70
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 33 deletions.
16 changes: 10 additions & 6 deletions docs/api/components_ItemGrid_ItemGrid.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -803,21 +803,25 @@
m.loadItemsTask.control = "stop"
return true
end if
else if key = "play"
else if key = "OK"
markupGrid = m.top.findNode("itemGrid")
itemToPlay = getItemFocused()

if itemToPlay <> invalid
m.top.quickPlayNode = itemToPlay
return true
else if itemToPlay <> invalid and itemToPlay.type = "Photo"
if itemToPlay <> invalid and itemToPlay.type = "Photo"
' Spawn photo player task
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.items = markupGrid
photoPlayer.itemsNode = markupGrid
photoPlayer.itemIndex = markupGrid.itemFocused
m.global.sceneManager.callfunc("pushScene", photoPlayer)
return true
end if
else if key = "play"
itemToPlay = getItemFocused()

if itemToPlay <> invalid
m.top.quickPlayNode = itemToPlay
return true
end if
else if key = "left" and topGrp.isinFocusChain()
m.top.alphaActive = true
topGrp.setFocus(false)
Expand Down
28 changes: 27 additions & 1 deletion docs/api/components_data_HomeData.bs.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion docs/api/components_home_Home.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
m.top.setFocus(true)
end if

refresh()
if not m.isFirstRun
refresh()
end if

' post the device profile the first time this screen is loaded
if m.isFirstRun
Expand Down
34 changes: 34 additions & 0 deletions docs/api/components_home_HomeItem.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
m.itemText.maxWidth = itemData.imageWidth
m.itemTextExtra.width = itemData.imageWidth
m.itemTextExtra.visible = true
m.itemTextExtra.text = ""

m.backdrop.width = itemData.imageWidth

Expand Down Expand Up @@ -181,6 +182,7 @@
else
m.itemPoster.uri = itemData.thumbnailURL
end if

return
end if

Expand Down Expand Up @@ -263,6 +265,38 @@
return
end if

if itemData.type = "Photo"
m.itemText.text = itemData.name
m.itemPoster.uri = ImageURL(itemData.id)

' subtext
if isValidAndNotEmpty(itemData.json)
if isValid(itemData.json.ProductionYear)
m.itemTextExtra.text = itemData.json.ProductionYear.ToStr().trim()
end if
if isValidAndNotEmpty(itemData.json.Album)
if m.itemTextExtra.text = ""
m.itemTextExtra.text = tr("Album") + ": " + itemData.json.Album.trim()
else
m.itemTextExtra.text = m.itemTextExtra.text + " - " + tr("Album") + ": " + itemData.json.Album.trim()
end if
end if
end if
return
end if

if itemData.type = "PhotoAlbum"
m.itemText.text = itemData.name
m.itemPoster.uri = ImageURL(itemData.id)

' subtext
if isValid(itemData.json.ChildCount)
m.itemTextExtra.text = itemData.json.ChildCount.ToStr().trim() + " items"
end if

return
end if

m.log.warn("Unhandled Home Item Type", itemData.type)
end sub

Expand Down
7 changes: 0 additions & 7 deletions docs/api/components_home_HomeRows.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,6 @@

' Update home row data
sub updateHomeRows()
if m.global.playstateTask.state = "run"
m.global.playstateTask.observeField("state", "updateHomeRows")
return
end if

m.global.playstateTask.unobserveField("state")

' If resume section exists, reload row's data
if m.homeSectionIndexes.doesExist("resume")
m.LoadContinueWatchingTask.observeField("content", "updateContinueWatchingItems")
Expand Down
20 changes: 14 additions & 6 deletions docs/api/components_photos_LoadPhotoTask.bs.html

Large diffs are not rendered by default.

62 changes: 56 additions & 6 deletions docs/api/components_photos_PhotoDetails.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@
sub itemContentChanged()
if isValidToContinue(m.top.itemIndex)
m.LoadLibrariesTask = createObject("roSGNode", "LoadPhotoTask")
itemContent = m.top.items.content.getChild(m.top.itemIndex)
m.LoadLibrariesTask.itemContent = itemContent
if isValid(m.top.itemsNode)
if isValid(m.top.itemsNode.content)
m.LoadLibrariesTask.itemNodeContent = m.top.itemsNode.content.getChild(m.top.itemIndex)
else if isValidAndNotEmpty(m.top.itemsNode.id)
m.LoadLibrariesTask.itemNodeContent = m.top.itemsNode
end if
else if isValid(m.top.itemsArray)
itemContent = m.top.itemsArray[m.top.itemIndex]
m.LoadLibrariesTask.itemArrayContent = itemContent
else
return
end if

m.LoadLibrariesTask.observeField("results", "onPhotoLoaded")
m.LoadLibrariesTask.control = "RUN"
end if
Expand Down Expand Up @@ -55,8 +66,22 @@
m.slideshowTimer.control = "start"
end if
else if m.random = true
index = rnd(m.top.items.content.getChildCount() - 1)
if isValidToContinue(index)
index = invalid

if isValid(m.top.itemsNode)
if isValidAndNotEmpty(m.top.itemsNode.content)
index = rnd(m.top.itemsNode.content.getChildCount() - 1)
else
' we're dealing with a single photo
return
end if
else if isValid(m.top.itemsArray)
if m.top.itemsArray.count() > 0
index = rnd(m.top.itemsArray.count() - 1)
end if
end if

if isValid(index) and isValidToContinue(index)
m.top.itemIndex = index
m.slideshowTimer.control = "start"
end if
Expand All @@ -68,6 +93,23 @@
m.hideStatusAnimation.control = "start"
end sub

' JFScreen hook.
' Used to ensure tasks are stopped
sub OnScreenHidden()
m.slideshowTimer.control = "stop"
m.statusTimer.control = "stop"
end sub

' isSlideshow component field has changed
sub isSlideshowChanged()
m.slideshow = m.top.isSlideshow
end sub

' isRandom component field has changed
sub isRandomChanged()
m.random = m.top.isRandom
end sub

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

Expand Down Expand Up @@ -118,8 +160,16 @@
end function

function isValidToContinue(index as integer)
if isValid(m.top.items) and isValid(m.top.items.content)
if index >= 0 and index < m.top.items.content.getChildCount()
if isValid(m.top.itemsNode)
if isValidAndNotEmpty(m.top.itemsNode.content)
if index >= 0 and index < m.top.itemsNode.content.getChildCount()
return true
end if
else if isValidAndNotEmpty(m.top.itemsNode) and index = 0
return true
end if
else if isValidAndNotEmpty(m.top.itemsArray)
if index >= 0 and index < m.top.itemsArray.count()
return true
end if
end if
Expand Down
2 changes: 1 addition & 1 deletion docs/api/data/search.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/module-PhotoDetails.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/module-quickplay.html

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion docs/api/source_Main.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@
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")
Expand Down Expand Up @@ -295,7 +299,31 @@
end if

else if selectedItemType = "Photo"
' Nothing to do here, handled in ItemGrid
' only handle selection if it's from the home screen
if selectedItem.isSubType("HomeData")
print "a photo was selected from the home screen"
print "selectedItem=", selectedItem

quickplay.photo(selectedItem)
end if
else if selectedItemType = "PhotoAlbum"
print "a photo album was selected"
print "selectedItem=", selectedItem

' grab all photos inside photo album
photoAlbumData = api.users.GetItemsByQuery(m.global.session.user.id, {
"parentId": selectedItem.id,
"includeItemTypes": "Photo",
"Recursive": true
})
print "photoAlbumData=", photoAlbumData

if isValid(photoAlbumData) and isValidAndNotEmpty(photoAlbumData.items)
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.itemsArray = photoAlbumData.items
photoPlayer.itemIndex = 0
m.global.sceneManager.callfunc("pushScene", photoPlayer)
end if
else if selectedItemType = "MusicArtist"
group = CreateArtistView(selectedItem.json)
if not isValid(group)
Expand Down
3 changes: 3 additions & 0 deletions docs/api/source_utils_misc.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@
if inputType = "string" or inputType = "rostring"
trimmedInput = input.trim()
return trimmedInput <> ""
else if inputType = "rosgnode"
inputId = input.id
return inputId <> invalid
else if countableTypes.doesExist(inputType)
return input.count() > 0
else
Expand Down
71 changes: 69 additions & 2 deletions docs/api/source_utils_quickplay.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,39 @@
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.isRandom = false
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)
Expand Down Expand Up @@ -372,6 +405,7 @@
}
' 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"
Expand All @@ -383,6 +417,11 @@
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
Expand All @@ -403,7 +442,16 @@
quickplay.multipleSeries(folderData.items)
end if
else
quickplay.pushToQueue(folderData.items, true)
if folderType = "photoalbum"
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.isSlideshow = true
photoPlayer.isRandom = false
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
Expand Down Expand Up @@ -517,7 +565,26 @@
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 library
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.isRandom = false
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
Expand Down

0 comments on commit c99ec70

Please sign in to comment.