Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
dratio
Level 7

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
Roku Employee
Roku Employee

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
Level 7

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
Level 7

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
Level 7

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
https://github.com/belltown/
0 Kudos
EnTerr
Level 8

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
Level 7

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
Highlighted
belltown
Level 7

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
https://github.com/belltown/
0 Kudos
dratio
Level 7

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
Level 7

Re: Trouble setting theme attributes from a URL.

Did you remember to call SetContent () on your list object after setting these images?
https://github.com/belltown/
0 Kudos