Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Roku roScreen slideshow list

I am trying to develop a slideshow app using the roScreen component that has a very large number of items (it can have around 11000 items which are roBitmaps each beeing put in a roSprite). In order to don't make a very large slides container I want the items to be dynamically loaded (i.e. the first 36 items are loaded at the beginning, and as the user scrolls the list, the next 18 items will be loaded and the first 18 items from the beginning of the list will be deleted. So, only 36 items will be present in the roCompositor at a given time). One more important thing to mention is that the images from the slideshow are taken from a remote server and temporarly saved into the local memory. Considering these, I have the following questions:

1) Can such a slideshow be implemented using the roScreen component or are there any limitations (i.e the viewport can only have 11000px lenght or any other limitations)? In my case after I delete the previous slides, still some of them remain visible on the screen and I can't draw any more.
2) Will downloading the images from the remote server to the temporary memory, in order to create the roBitmaps, fill the temporary memory? If yes, is it possible to clean it in some way?

Here is the portion of code that loads the slides:

loadSegment: function(loadFromBehind = false as Boolean, firstSegment = false as Boolean) as Void

v = getGlobalAA()

positionToDraw = 0
drawOffset = 0
itemsOffset = 0

' In case this is not the first segment of 36 items in the slideshow
if not firstSegment
itemsFetched = v.globals.listPageLength / 2 ' Here v.globals.listPageLength is 18

' Fetch the next 18 items
movies = WS_getMovieList("gm", m.offset, itemsFetched).its

' Remove the previous 18 items
for i = 0 to itemsFetched - 1
m.items.delete(i)
m.sprites[i].moveTo(-300, 180)
m.sprites[i].remove()
m.sprites.delete(i)
end for

drawOffset = 4
itemsOffset = itemsFetched
else
' Get the first initial 36 items
movies = WS_getMovieList("gm", m.offset, v.globals.listPageLength).its
end if

m.items.append(movies)

for i = itemsOffset to m.items.count() - 1
xhr = createObject("roUrlTransfer")
port = createObject("roMessagePort")
xhr.setMessagePort(port)

' Download the slide image into the temporary memory
xhr.setUrl(m.items[i].HDPosterUrl)
status = xhr.asyncGetToFile("tmp:/image.jpg")

msg = wait(300, port)

' Create a sprite using the downloaded image
if type(msg) = "roUrlEvent"
bitmap = createObject("roBitmap", "tmp:/image.jpg")
if type(bitmap) = "roBitmap"
m.bitmapWidth = bitmap.getWidth()
m.bitmapHeight = bitmap.getHeight()
region = createObject("roRegion", bitmap, 0, 0, m.bitmapWidth, m.bitmapHeight)
m.sprites.push(v.compositor.newSprite(70 + (m.bitmapWidth + 10) * (i - itemsOffset + drawOffset + positionToDraw), 180, region))
end if
end if
end for

' Draw everything on screen
v.compositor.drawAll()
v.screen.swapBuffers()

end function
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.