Merge pull request #523 from jimdogx/feature/211-Support-For-Photos

This commit is contained in:
Neil Burrows 2022-02-16 07:45:46 +00:00 committed by GitHub
commit 550457c73f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 187 additions and 5 deletions

View File

@ -48,6 +48,9 @@ sub itemContentChanged()
else if itemData.type = "Video"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else if itemData.type = "Photo"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else
print "Unhandled Grid Item Type: " + itemData.type
end if

View File

@ -94,7 +94,7 @@ sub loadInitialItems()
showTvGuide()
end if
else if m.top.parentItem.collectionType = "CollectionFolder" or m.top.parentItem.collectionType = "boxsets" or m.top.parentItem.Type = "Folder" or m.top.parentItem.Type = "Channel"
else if m.top.parentItem.collectionType = "CollectionFolder" or m.top.parentItem.type = "CollectionFolder" or m.top.parentItem.collectionType = "boxsets" or m.top.parentItem.Type = "Folder" or m.top.parentItem.Type = "Channel"
' Non-recursive, to not show subfolder contents
m.loadItemsTask.recursive = false
else if m.top.parentItem.collectionType = "Channel"
@ -177,6 +177,17 @@ sub SetUpOptions()
{ "Title": tr("All"), "Name": "All" },
{ "Title": tr("Favorites"), "Name": "Favorites" }
]
else if m.top.parentItem.collectionType = "photoalbum" or m.top.parentItem.collectionType = "photo" or m.top.parentItem.collectionType = "homevideos"
' For some reason, my photo library shows up as "homevideos", maybe because it has some mp4 mixed in with the jpgs?
' TODO/FIXME: Show shuffle options once implemented
' options.views = [
' { "Title": tr("Don't Shuffle"), "Name": "singlephoto"}
' { "Title": tr("Shuffle"), "Name": "shufflephoto"}
' ]
options.views = []
options.sort = []
options.filter = []
else
options.views = [
{ "Title": tr("Default"), "Name": "default" }
@ -351,6 +362,17 @@ sub optionsClosed()
end if
if m.top.parentItem.Type = "CollectionFolder" or m.top.parentItem.CollectionType = "CollectionFolder"
' Did the user just request "Shuffle" on a PhotoAlbum?
if m.options.view = "singlephoto"
' TODO/FIXME: Stop shuffling here
print "TODO/FIXME: Stop any shuffling here"
else if m.options.view = "shufflephoto"
' TODO/FIXME: Start shuffling here
print "TODO/FIXME: Start shuffle here"
end if
end if
reload = false
if m.options.sortField <> m.sortField or m.options.sortAscending <> m.sortAscending
m.sortField = m.options.sortField
@ -438,13 +460,19 @@ function onKeyEvent(key as string, press as boolean) as boolean
optionsClosed()
return true
end if
else if key = "play"
else if key = "play" or key = "OK"
markupGrid = m.top.getChild(2)
itemToPlay = markupGrid.content.getChild(markupGrid.itemFocused)
if itemToPlay <> invalid and (itemToPlay.type = "Movie" or itemToPlay.type = "Episode")
m.top.quickPlayNode = itemToPlay
return true
else if itemToPlay <> invalid and itemToPlay.type = "Photo"
' Spawn photo player task
photoPlayer = CreateObject("roSgNode", "PhotoPlayerTask")
photoPlayer.itemContent = itemToPlay
photoPlayer.control = "RUN"
return true
end if
return true
end if
return false
end function

View File

@ -65,6 +65,10 @@ sub loadItems()
tmp = CreateObject("roSGNode", "FolderData")
else if item.Type = "Video"
tmp = CreateObject("roSGNode", "VideoData")
else if item.Type = "Photo"
tmp = CreateObject("roSGNode", "PhotoData")
else if item.type = "PhotoAlbum"
tmp = CreateObject("roSGNode", "FolderData")
else
print "[LoadItems] Unknown Type: " item.Type
end if

View File

@ -5,6 +5,7 @@
<field id="lastFocus" type="node" />
<field id="overhangTitle" type="string" />
<field id="optionsAvailable" value="true" type="boolean" />
<field id="overhangVisible" value="true" type="boolean" />
</interface>
<script type="text/brightscript" uri="JFGroup.brs" />
</component>

View File

@ -28,7 +28,6 @@ sub init()
updateTimeDisplay()
end sub
sub updateTitle()
leftSeperator = m.top.findNode("overlayLeftSeperator")
if m.top.title <> ""

View File

@ -0,0 +1,34 @@
sub setFields()
json = m.top.json
m.top.id = json.id
m.top.Title = json.name
m.top.Type = "Photo"
setPoster()
end sub
sub setPoster()
if m.top.image <> invalid
m.top.posterURL = m.top.image.url
else
if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
else if m.top.json.BackdropImageTags[0] <> invalid
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
else if m.top.json.ParentThumbImageTag <> invalid and m.top.json.ParentThumbItemId <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ParentThumbImageTag }
m.top.posterURL = ImageURL(m.top.json.ParentThumbItemId, "Thumb", imgParams)
end if
' Add Backdrop Image
if m.top.json.BackdropImageTags[0] <> invalid
imgParams = { "maxHeight": 720, "maxWidth": 1280, "Tag": m.top.json.BackdropImageTags[0] }
m.top.backdropURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
end if
end if
end sub

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="PhotoData" extends="JFContentItem">
<interface>
<field id="image" type="node" onChange="setPoster" />
<field id="photoID" type="string" />
</interface>
<script type="text/brightscript" uri="PhotoData.brs" />
<script type="text/brightscript" uri="pkg:/source/api/Image.brs" />
<script type="text/brightscript" uri="pkg:/source/api/baserequest.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
</component>

View File

@ -129,7 +129,13 @@ sub registerOverhangData(group)
group.observeField("optionsAvailable", "updateOptions")
group.observeField("overhangTitle", "updateOverhangTitle")
m.overhang.visible = true
if group.overhangVisible
m.overhang.visible = true
else
m.overhang.visible = false
end if
group.observeField("overhangVisible", "updateOverhangVisible")
else if group.isSubType("JFVideo")
m.overhang.visible = false
else
@ -159,6 +165,13 @@ sub updateOptions(msg)
end sub
'
' Update whether the overhang is visible or not
sub updateOverhangVisible(msg)
m.overhang.visible = msg.getData()
end sub
'
' Update username in overhang
sub updateUser()

View File

@ -0,0 +1,16 @@
sub init()
m.top.functionName = "loadItems"
end sub
sub loadItems()
item = m.top.itemContent
if item <> invalid
params = {
maxHeight: 1080
maxWidth: 1920
}
m.top.results = ImageURL(item.Id, "Primary", params)
else
m.top.results = invalid
end if
end sub

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="LoadPhotoTask" extends="Task">
<interface>
<field id="itemContent" type="node" />
<field id="results" type="string" />
</interface>
<script type="text/brightscript" uri="LoadPhotoTask.brs" />
<script type="text/brightscript" uri="pkg:/source/api/Image.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
<script type="text/brightscript" uri="pkg:/source/api/baserequest.brs" />
</component>

View File

@ -0,0 +1,21 @@
sub init()
m.top.optionsAvailable = false ' Change once Shuffle option is added
m.top.overhangVisible = false
end sub
sub itemContentChanged()
m.LoadLibrariesTask = createObject("roSGNode", "LoadPhotoTask")
m.LoadLibrariesTask.itemContent = m.top.itemContent
m.LoadLibrariesTask.observeField("results", "onPhotoLoaded")
m.LoadLibrariesTask.control = "RUN"
end sub
sub onPhotoLoaded()
if m.LoadLibrariesTask.results <> invalid
photo = m.top.findNode("photo")
photo.uri = m.LoadLibrariesTask.results
else
'Show user error here (for example if it's not a supported image type)
message_dialog("This image type is not supported.")
end if
end sub

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="PhotoDetails" extends="JFGroup">
<children>
<LayoutGroup id="toplevel">
<Poster id="photo" width="1920" height="1080" loadDisplayMode="scaleToFit"/>
</LayoutGroup>
</children>
<interface>
<field id="itemContent" type="node" onChange="itemContentChanged" />
</interface>
<script type="text/brightscript" uri="PhotoDetails.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/misc.brs" />
</component>

View File

@ -0,0 +1,17 @@
sub init()
m.top.functionName = "loadItems"
end sub
sub loadItems()
item = m.top.itemContent
group = CreateObject("roSGNode", "PhotoDetails")
group.optionsAvailable = false
m.global.sceneManager.callFunc("pushScene", group)
group.itemContent = item
' TODO/FIXME:
' Wait some time and move to the next photo...
end sub

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="PhotoPlayerTask" extends="Task">
<interface>
<field id="itemContent" type="node" />
</interface>
<script type="text/brightscript" uri="PhotoPlayerTask.brs" />
</component>

View File

@ -135,6 +135,8 @@ sub Main (args as dynamic) as void
m.scene.dialog = dialog
m.scene.dialog.observeField("buttonSelected", m.port)
end if
else if selectedItem.type = "Photo"
' Nothing to do here, handled in ItemGrid
else
' TODO - switch on more node types
message_dialog("This type is not yet supported: " + selectedItem.type + ".")