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

Trouble setting theme attributes from a URL.

I am trying to set the asset for an overhang slice like so:

app.setThemeAttribute("GridScreenOverhangSliceHD", overhangSlice)

where overhangSlice is a URL to a web hosted image. The image will not actually display with any consistency. Any idea why this would be? Thanks
0 Kudos
22 REPLIES 22
RokuJoel
Binge Watcher

Re: Trouble setting theme attributes from a URL.

Since you say "with any consistency" I'm going to assume that it is working some of the time.

After you set the them, put in a sleep(500) and see if that helps.

Officially themes don't support loading over the internet, so technically this is unsupported.

- Joel
0 Kudos
TheEndless
Channel Surfer

Re: Trouble setting theme attributes from a URL.

You'd probably be better off downloading the images to tmp:, and using the tmp: path in your theme.
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
dratio
Visitor

Re: Trouble setting theme attributes from a URL.

Thanks a bunch for the replies, I will try putting a sleep on it. It's the oddest thing though, I am able to set certain images anywhere, but then attempting to set the same item with different images the images do not display. I print out the url of each image to ensure that it is being addressed correctly to the object which will be displaying the image, even when the url is correct, only certain images are able to be displayed. In the even that sleep doesn't work, what's the easiest way to download the images to tmp? Is there a method to call?
0 Kudos
belltown
Roku Guru

Re: Trouble setting theme attributes from a URL.

"dratio" wrote:
Thanks a bunch for the replies, I will try putting a sleep on it. It's the oddest thing though, I am able to set certain images anywhere, but then attempting to set the same item with different images the images do not display. I print out the url of each image to ensure that it is being addressed correctly to the object which will be displaying the image, even when the url is correct, only certain images are able to be displayed. In the even that sleep doesn't work, what's the easiest way to download the images to tmp? Is there a method to call?

The easiest way to download an image to a tmp file is probably using an roUrlTransfer object with method GetToFile:


tmpFile = "tmp:/image.jpg"
ut = CreateObject ("roUrlTransfer")
ut.SetUrl ("... image url ...")
responseCode = ut.GetToFile (tmpFile)
If responseCode = 200
' Success
Else
' Failed
Endif
0 Kudos
EnTerr
Roku Guru

Re: Trouble setting theme attributes from a URL.

"dratio" wrote:
It's the oddest thing though, I am able to set certain images anywhere, but then attempting to set the same item with different images the images do not display.

Are you setting the attribute before displaying the component for the first time - or if already shown, are you calling .show() (or equivalent) to refresh it? I don't think that changes to the global theme affect like magic already rendered component - or at least it's YMMV.
0 Kudos
dratio
Visitor

Re: Trouble setting theme attributes from a URL.

If you don't mind looking, here is part of the function where the problem exists. I am passing in an object that contains parsed XML (aboutOptions), the problem is with SmallIconUrl. If I set it to aboutOptions.background, it displays the image, however, anything else that I try to set it to does not work. I've tried another attribute on the aboutOptions, or a direct url to an image...and I just tried setting it to tmpFile (displayed in the code), which I created using the snippet belltown provided. What am I doing wrong here? Thanks


tmpFile = CreateObject("roUrlTransfer")
tmpFile.SetUrl(aboutOptions.logo)
tmpFile.GetToFile("tmp:/about_small.png")

o.SDSmallIconUrl = tmpFile
o.HDSmallIconUrl = tmpFile
o.HDBackgroundImageUrl = aboutOptions.background
o.SDBackgroundImageUrl = aboutOptions.background
0 Kudos
belltown
Roku Guru

Re: Trouble setting theme attributes from a URL.

Try this:


tmpfile = "tmp:/about_small.png"
urlTransferObject = CreateObject("roUrlTransfer")
urlTransferObject.SetUrl(aboutOptions.logo)
urlTransferObject.GetToFile(tmpfile)

o.SDSmallIconUrl = tmpFile
o.HDSmallIconUrl = tmpFile
o.HDBackgroundImageUrl = aboutOptions.background
o.SDBackgroundImageUrl = aboutOptions.background
0 Kudos
dratio
Visitor

Re: Trouble setting theme attributes from a URL.

I've attempted that as well and it is not working. I'm not sure what the deal is. It really just does not want to let me set a remote image on that item.
0 Kudos
belltown
Roku Guru

Re: Trouble setting theme attributes from a URL.

Did you remember to call SetContent () on your list object after setting these images?
0 Kudos