Your Digital Media Has Never Looked So Good

 
dratio
Topic Author
Posts: 17
Joined: Thu Sep 11, 2014 11:29 am

Trouble setting theme attributes from a URL.

Fri Sep 19, 2014 10:59 am

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
 
User avatar
RokuJoel
Posts: 1758
Joined: Mon Nov 14, 2011 5:22 pm

Re: Trouble setting theme attributes from a URL.

Fri Sep 19, 2014 11:54 am

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
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: Trouble setting theme attributes from a URL.

Fri Sep 19, 2014 1:16 pm

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)
 
dratio
Topic Author
Posts: 17
Joined: Thu Sep 11, 2014 11:29 am

Re: Trouble setting theme attributes from a URL.

Mon Sep 22, 2014 8:01 am

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?
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: Trouble setting theme attributes from a URL.

Mon Sep 22, 2014 12:20 pm

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/
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Trouble setting theme attributes from a URL.

Mon Sep 22, 2014 4:45 pm

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.
 
dratio
Topic Author
Posts: 17
Joined: Thu Sep 11, 2014 11:29 am

Re: Trouble setting theme attributes from a URL.

Tue Sep 23, 2014 10:22 am

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
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: Trouble setting theme attributes from a URL.

Tue Sep 23, 2014 10:27 am

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/
 
dratio
Topic Author
Posts: 17
Joined: Thu Sep 11, 2014 11:29 am

Re: Trouble setting theme attributes from a URL.

Tue Sep 23, 2014 2:23 pm

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.
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: Trouble setting theme attributes from a URL.

Tue Sep 23, 2014 2:37 pm

Did you remember to call SetContent () on your list object after setting these images?
https://github.com/belltown/
 
dratio
Topic Author
Posts: 17
Joined: Thu Sep 11, 2014 11:29 am

Re: Trouble setting theme attributes from a URL.

Tue Sep 23, 2014 2:42 pm

I'm setting the object ("o" in this case) with those values in a separate function and having it return the object and calling screen.SetContent(o) where screen is the roListScreen object.
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: Trouble setting theme attributes from a URL.

Tue Sep 23, 2014 2:51 pm

You could also try examining the GetToFile response code just to make sure the icon file is being read from the url you specified:

responseCode = urlTransferObject.GetToFile(tmpfile)
print responseCode


It should be 200 for a successful response.
https://github.com/belltown/
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Trouble setting theme attributes from a URL.

Tue Sep 23, 2014 3:52 pm

dratio wrote:
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.

Wait a minute, you are all over the map!
The topic was about theme attributes, now you are talking about HdBackgroundImageUrl and HdSmallIconUrl of roListScreen - which are not theme-related. Choose one issue and focus on it until resolved - then post separate question on another one.

I have used roListScreen and can tell you those things work fine with remote images, WITHOUT having to download locally.

PS. Meta-dating is finicky. For example your posted code, you are setting o.SDSmallIconUrl to a roUrlTransfer object, which is wrongedy wrong - but the component won't tell you that, instead will quietly* pretend it was set to invalid. You can only put STRINGS in those attributes that expect URL, that is - a text starting with "http://", "tmp:/" etc

(*) setting attribute to a wrong data TYPE should be a runtime error (vs say a warning if metadata item did not load from URL) - but it isn't (yet?)
 
dratio
Topic Author
Posts: 17
Joined: Thu Sep 11, 2014 11:29 am

Re: Trouble setting theme attributes from a URL.

Wed Sep 24, 2014 9:06 am

EnTerr wrote:
The topic was about theme attributes, now you are talking about HdBackgroundImageUrl and HdSmallIconUrl of roListScreen - which are not theme-related. Choose one issue and focus on it until resolved - then post separate question on another one.


yeah, you're right. I was talking about setting images on the roListScreen, which isn't a part of a theme, I just associated with the theme because it is set similarly to the way the theme is set.

I recognize that I was setting it to the roUrlTransfer object, and I should have been setting it to the path. However, correcting that still did not work. The thing that I'm not understanding is that I am able to set certain images from a URL, but others I am not and it appears that there is no rhyme or reason for it.
 
dratio
Topic Author
Posts: 17
Joined: Thu Sep 11, 2014 11:29 am

Re: Trouble setting theme attributes from a URL.

Wed Sep 24, 2014 9:08 am

belltown wrote:
You could also try examining the GetToFile response code just to make sure the icon file is being read from the url you specified:

responseCode = urlTransferObject.GetToFile(tmpfile)
print responseCode


It should be 200 for a successful response.


I do have it in an if statement that checks if the response code is 200 before assignment, I just put in the relevant code so that it wasn't a massive snippet of code when there were only a couple of lines that matter. I'm pretty baffled as to why it won't work.

Who is online

Users browsing this forum: No registered users and 17 guests