Initial support for photo viewing

This commit is contained in:
Jimi 2022-02-06 08:37:02 -07:00
parent 2ed757a7a6
commit bc5c61a519
10 changed files with 124 additions and 0 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

@ -65,6 +65,8 @@ 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
print "[LoadItems] Unknown Type: " item.Type
end if

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

@ -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,20 @@
sub init()
m.top.optionsAvailable = 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

@ -135,6 +135,9 @@ 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"
' Show selected photo
group = CreatePhotoPage(selectedItem)
else
' TODO - switch on more node types
message_dialog("This type is not yet supported: " + selectedItem.type + ".")

View File

@ -375,6 +375,16 @@ function CreateVideoPlayerGroup(video_id, audio_stream_idx = 1)
return video
end function
function CreatePhotoPage(photo)
group = CreateObject("roSGNode", "PhotoDetails")
group.optionsAvailable = false
m.global.sceneManager.callFunc("pushScene", group)
group.itemContent = photo
return group
end function
sub UpdateSavedServerList()
server = get_setting("server")
username = get_setting("username")