Merge pull request #855 from jimdogx/feature/jf-photo-slideshow

Feature/jf photo slideshow
This commit is contained in:
1hitsong 2022-12-06 10:33:57 -05:00 committed by GitHub
commit 8116babee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 171 additions and 61 deletions

View File

@ -320,13 +320,14 @@ end sub
' Set Photo Album view, sort, and filter options ' Set Photo Album view, sort, and filter options
sub setPhotoAlbumOptions(options) sub setPhotoAlbumOptions(options)
' TODO/FIXME: Show shuffle options once implemented options.views = [
' options.views = [ { "Title": tr("Slideshow Off"), "Name": "singlephoto" }
' { "Title": tr("Don't Shuffle"), "Name": "singlephoto"} { "Title": tr("Slideshow On"), "Name": "slideshowphoto" }
' { "Title": tr("Shuffle"), "Name": "shufflephoto"} { "Title": tr("Random Off"), "Name": "singlephoto" }
' ] { "Title": tr("Random On"), "Name": "randomphoto" }
options.views = [] ]
options.sort = [] options.sort = []
options.filter = []
end sub end sub
' Set Default view, sort, and filter options ' Set Default view, sort, and filter options
@ -574,14 +575,17 @@ sub optionsClosed()
end if end if
end if end if
if m.top.parentItem.Type = "CollectionFolder" or m.top.parentItem.CollectionType = "CollectionFolder" if m.top.parentItem.Type = "CollectionFolder" or m.top.parentItem.Type = "Folder" or m.top.parentItem.CollectionType = "CollectionFolder"
' Did the user just request "Shuffle" on a PhotoAlbum? ' Did the user just request "Random" on a PhotoAlbum?
if m.options.view = "singlephoto" if m.options.view = "singlephoto"
' TODO/FIXME: Stop shuffling here set_user_setting("photos.slideshow", "false")
print "TODO/FIXME: Stop any shuffling here" set_user_setting("photos.random", "false")
else if m.options.view = "shufflephoto" else if m.options.view = "slideshowphoto"
' TODO/FIXME: Start shuffling here set_user_setting("photos.slideshow", "true")
print "TODO/FIXME: Start shuffle here" set_user_setting("photos.random", "false")
else if m.options.view = "randomphoto"
set_user_setting("photos.random", "true")
set_user_setting("photos.slideshow", "false")
end if end if
end if end if
@ -724,9 +728,10 @@ function onKeyEvent(key as string, press as boolean) as boolean
return true return true
else if itemToPlay <> invalid and itemToPlay.type = "Photo" else if itemToPlay <> invalid and itemToPlay.type = "Photo"
' Spawn photo player task ' Spawn photo player task
photoPlayer = CreateObject("roSgNode", "PhotoPlayerTask") photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.itemContent = itemToPlay photoPlayer.items = markupGrid
photoPlayer.control = "RUN" photoPlayer.itemIndex = markupGrid.itemFocused
m.global.sceneManager.callfunc("pushScene", photoPlayer)
return true return true
end if end if
else if key = "left" and topGrp.isinFocusChain() else if key = "left" and topGrp.isinFocusChain()

View File

@ -1,21 +1,123 @@
sub init() sub init()
m.top.optionsAvailable = false ' Change once Shuffle option is added m.top.optionsAvailable = true
m.top.overhangVisible = false m.top.overhangVisible = false
m.slideshowTimer = m.top.findNode("slideshowTimer")
m.slideshowTimer.observeField("fire", "nextSlide")
m.status = m.top.findNode("status")
m.textBackground = m.top.findNode("background")
m.statusTimer = m.top.findNode("statusTimer")
m.statusTimer.observeField("fire", "statusUpdate")
m.slideshow = get_user_setting("photos.slideshow")
m.random = get_user_setting("photos.random")
m.showStatusAnimation = m.top.findNode("showStatusAnimation")
m.hideStatusAnimation = m.top.findNode("hideStatusAnimation")
itemContentChanged()
end sub end sub
sub itemContentChanged() sub itemContentChanged()
m.LoadLibrariesTask = createObject("roSGNode", "LoadPhotoTask") if isValidToContinue(m.top.itemIndex)
m.LoadLibrariesTask.itemContent = m.top.itemContent m.LoadLibrariesTask = createObject("roSGNode", "LoadPhotoTask")
m.LoadLibrariesTask.observeField("results", "onPhotoLoaded") itemContent = m.top.items.content.getChild(m.top.itemIndex)
m.LoadLibrariesTask.control = "RUN" m.LoadLibrariesTask.itemContent = itemContent
m.LoadLibrariesTask.observeField("results", "onPhotoLoaded")
m.LoadLibrariesTask.control = "RUN"
end if
end sub end sub
sub onPhotoLoaded() sub onPhotoLoaded()
if m.LoadLibrariesTask.results <> invalid if m.LoadLibrariesTask.results <> invalid
photo = m.top.findNode("photo") photo = m.top.findNode("photo")
photo.uri = m.LoadLibrariesTask.results photo.uri = m.LoadLibrariesTask.results
if m.slideshow = "true" or m.random = "true"
' user has requested either a slideshow or random...
m.slideshowTimer.control = "start"
end if
else else
'Show user error here (for example if it's not a supported image type) 'Show user error here (for example if it's not a supported image type)
message_dialog("This image type is not supported.") message_dialog("This image type is not supported.")
end if end if
end sub end sub
sub nextSlide()
m.slideshowTimer.control = "stop"
if m.slideshow = "true"
if isValidToContinue(m.top.itemIndex + 1)
m.top.itemIndex++
m.slideshowTimer.control = "start"
end if
else if m.random = "true"
index = rnd(m.top.items.content.getChildCount() - 1)
if isValidToContinue(index)
m.top.itemIndex = index
m.slideshowTimer.control = "start"
end if
end if
end sub
sub statusUpdate()
m.statusTimer.control = "stop"
m.hideStatusAnimation.control = "start"
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "right"
if isValidToContinue(m.top.itemIndex + 1)
m.slideshowTimer.control = "stop"
m.top.itemIndex++
end if
return true
end if
if key = "left"
if isValidToContinue(m.top.itemIndex - 1)
m.slideshowTimer.control = "stop"
m.top.itemIndex--
end if
return true
end if
if key = "play"
if m.slideshowTimer.control = "start"
' stop the slideshow if the user hits "pause"
m.slideshowTimer.control = "stop"
m.status.text = tr("Slideshow Paused")
if m.textBackground.opacity = 0
m.showStatusAnimation.control = "start"
end if
m.statusTimer.control = "start"
else
' start the slideshow if the user hits "play"
m.status.text = tr("Slideshow Resumed")
if m.textBackground.opacity = 0
m.showStatusAnimation.control = "start"
end if
m.slideshow = "true"
m.statusTimer.control = "start"
m.slideshowTimer.control = "start"
end if
return true
end if
if key = "options"
' Options (random etc) is done on itemGrid
return true
end if
return false
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()
return true
end if
end if
return false
end function

View File

@ -1,13 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<component name="PhotoDetails" extends="JFGroup"> <component name="PhotoDetails" extends="JFGroup">
<children> <children>
<LayoutGroup id="toplevel"> <Poster id="photo" width="1920" height="1080" loadDisplayMode="scaleToFit"/>
<Poster id="photo" width="1920" height="1080" loadDisplayMode="scaleToFit"/> <Rectangle id="background" color="0x101010EE" height="120" width="500" Translation="[700, -150]" opacity="0">
</LayoutGroup> <Label id="status" font="font:MediumSystemFont" height="100" width="500" horizAlign="center" vertAlign="bottom"/>
</Rectangle>
<Timer id="slideshowTimer" duration="5" repeat="false" />
<Timer id="statusTimer" duration="2" repeat="false" />
<Animation id="showStatusAnimation" duration="1" repeat="false">
<FloatFieldInterpolator key="[0.0, 0.1]" keyValue="[0, 1]" fieldToInterp="background.opacity" />
<Vector2DFieldInterpolator key="[0.1, 1]" keyValue="[[700, -150], [700, -5]]" fieldToInterp="background.translation" />
</Animation>
<Animation id="hideStatusAnimation" duration="1" repeat="false">
<Vector2DFieldInterpolator key="[0.0, 0.9]" keyValue="[[700, -5], [700, -150]]" fieldToInterp="background.translation" />
<FloatFieldInterpolator key="[0.9, 1]" keyValue="[1, 0]" fieldToInterp="background.opacity" />
</Animation>
</children> </children>
<interface> <interface>
<field id="itemContent" type="node" onChange="itemContentChanged" /> <field id="items" type="node" />
<field id="itemIndex" type="integer" value="-1" onChange="itemContentChanged" />
</interface> </interface>
<script type="text/brightscript" uri="PhotoDetails.brs" /> <script type="text/brightscript" uri="PhotoDetails.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/misc.brs" /> <script type="text/brightscript" uri="pkg:/source/utils/misc.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
</component> </component>

View File

@ -1,17 +0,0 @@
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

@ -1,8 +0,0 @@
<?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

@ -850,6 +850,30 @@
<translation>Unable to find any albums or songs belonging to this artist</translation> <translation>Unable to find any albums or songs belonging to this artist</translation>
<extracomment>Popup message when we find no audio data for an artist</extracomment> <extracomment>Popup message when we find no audio data for an artist</extracomment>
</message> </message>
<message>
<source>Slideshow Off</source>
<translation>Slideshow Off</translation>
</message>
<message>
<source>Slideshow On</source>
<translation>Slideshow On</translation>
</message>
<message>
<source>Slideshow Paused</source>
<translation>Slideshow Paused</translation>
</message>
<message>
<source>Slideshow Resumed</source>
<translation>Slideshow Resumed</translation>
</message>
<message>
<source>Random Off</source>
<translation>Random Off</translation>
</message>
<message>
<source>Random On</source>
<translation>Random On</translation>
</message>
<message> <message>
<source>MPEG-4 Support</source> <source>MPEG-4 Support</source>
<translation>MPEG-4 Support</translation> <translation>MPEG-4 Support</translation>

View File

@ -592,17 +592,6 @@ function CreatePersonView(personData as object) as object
return person return person
end function end function
function CreatePhotoPage(photo)
group = CreateObject("roSGNode", "PhotoDetails")
group.optionsAvailable = true
m.global.sceneManager.callFunc("pushScene", group)
group.itemContent = photo
return group
end function
sub UpdateSavedServerList() sub UpdateSavedServerList()
server = get_setting("server") server = get_setting("server")
username = get_setting("username") username = get_setting("username")