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: 
agmark
Visitor

Refreshing Images

I'm grabbing some images from a URL and displaying them on a roImageCanvas, but when I grab the updated image with the same url the screen doesn't display the fresh image. All I've seen in the docs is the PurgeCachedImages() method, but I'm not able toget that to work. I'm using the CustomVideoPlayer as the structure of the channel and I'm displaying the images in the following code snippet.
m.canvas.AllowUpdates(false)
m.canvas.Clear()
m.canvas.purgecachedimages()
m.canvas.SetLayer(0, [
{ url: "http://my.images.com/image?ID_NOTATION=324977&HEIGHT=75&WIDTH=120&TIME_SPAN=1"
TargetRect: m.layout.image1
'CompositionMode: "Source_Over"
},

more images here etc

What's the solution to purge the images so new ones will display?
TIA
Mark
0 Kudos
4 REPLIES 4
TheEndless
Channel Surfer

Re: Refreshing Images

Images are cached based on the URL, so if you want to force an update, the easiest way is to add a random value to the querystring, so the URL changes.

Pseudo-example...
date = CreateObject("roDateTime")
...
url: "http://my.images.com/image?ID_NOTATION=324977&HEIGHT=75&WIDTH=120&TIME_SPAN=1&nocache=" + date.AsSeconds().ToStr()
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
agmark
Visitor

Re: Refreshing Images

Hey thanks for that Endless! Works perfect and it's good to know.
Mark
0 Kudos
buenafe
Visitor

PurgeCachedImages

The work around solved the problem.

However, I'm curious to know what "PurgeCachedImages()" is doing (or should be doing) .
----------------------------------------------------------------------------------
current: two roku XDS 2xs, dtvpal, boxeebox, kylo.tv,
radar: wdlxtv.com
0 Kudos
Trevor
Visitor

Re: Refreshing Images

From http://sdkdocs.roku.com/display/sdkdoc42/ifImageCanvas
PurgeCachedImages: This is a convenience method that will purge the internal cache of all images related to urls in the current content list. If the content list is empty, then this method will do nothing.
*** Trevor Anderson - bloggingwordpress.com - moviemavericks.com ***
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.