Skip to content

Commit

Permalink
turn random off when quickplaying photos + fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert committed Nov 14, 2023
1 parent eedb277 commit d9be2dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions components/photos/PhotoDetails.bs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ sub nextSlide()
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 isValid(m.top.itemsArray.count() > 0)
if m.top.itemsArray.count() > 0
index = rnd(m.top.itemsArray.count() - 1)
end if
end if

if isValidToContinue(index)
if isValid(index) and isValidToContinue(index)
m.top.itemIndex = index
m.slideshowTimer.control = "start"
end if
Expand All @@ -100,6 +103,11 @@ 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
1 change: 1 addition & 0 deletions components/photos/PhotoDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<field id="itemsNode" type="node" />
<field id="itemsArray" type="roArray" />
<field id="isSlideshow" type="bool" onChange="isSlideshowChanged" />
<field id="isRandom" type="bool" onChange="isRandomChanged" />
<field id="itemIndex" type="integer" value="-1" onChange="itemContentChanged" />
</interface>
</component>
5 changes: 4 additions & 1 deletion source/utils/quickplay.bs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace quickplay
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)
Expand Down Expand Up @@ -442,6 +443,7 @@ namespace quickplay
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)
Expand Down Expand Up @@ -564,7 +566,7 @@ namespace quickplay
else if collectionType = "homevideos"
' Photo library - items can be type video, photo, or photoAlbum

' grab all photos inside photo album
' grab all photos inside library
folderData = api.users.GetItemsByQuery(m.global.session.user.id, {
"parentId": itemNode.id,
"includeItemTypes": "Photo",
Expand All @@ -576,6 +578,7 @@ namespace quickplay
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)
Expand Down

0 comments on commit d9be2dd

Please sign in to comment.