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: 
rossoneri
Binge Watcher

issue loading image from package

Jump to solution

I'm loading an image from the web for my poster, but I want to add a test in case the image doesn't load properly, in which case I will load an image from the package.  I have no issue loading from the web, but loading from the package doesn't work.

 

Function init()
    m.BackgroundArt = m.top.findNode("BackgroundArt")	
    m.BackgroundArt.observeField("loadStatus", "posterLoadStatus")

    m.BackgroundArt.uri = "https://imagewillfail.com"   
End Function


Function posterLoadStatus(event as Object)
    loadStatus = event.getData()
    if loadStatus = "failed"
        print m.BackgroundArt.uri
        print "poster1 failed to load"
        m.BackgroundArt.uri = "pkg:/images/bg.jpg"
    end if
End Function

The result of this is

https://imagewillfail.com
poster1 failed to load
pkg:/images/bg.jpg
poster1 failed to load

I'm really at a loss for ideas, the image is definitely in the zip, but for some reason it just won't load.  

 

 

--------------

 

EDIT: The issue is that I edited my images in gimp which has the "progressive" option selected by default when exporting jpegs, this option is apparently not supported by roku.  

0 Kudos
1 Solution

Accepted Solutions
joetesta
Roku Guru

Re: issue loading image from package

Jump to solution

There are a couple reasons that images will fail to work, one is interlacing.
Like @cocotower suggests try replacing that image with some other existing .png file that you know works, maybe from an example app.  If it does appear, the problem is your image file.  If it does not appear, the problem is something with your folder or view structure or perhaps a typo - anything in debug output?

 

aspiring

View solution in original post

9 REPLIES 9
cocotower
Roku Guru

Re: issue loading image from package

Jump to solution

@rossoneri wrote:
Function init()
    m.BackgroundArt = m.top.findNode("BackgroundArt")	
    m.BackgroundArt.observeField("loadStatus", "posterLoadStatus")

    m.BackgroundArt.uri = "https://imagewillfail.com"   
End Function


Function posterLoadStatus(event as Object)
    loadStatus = event.getData()
    if loadStatus = "failed"
        print m.BackgroundArt.uri
        print "poster1 failed to load"
        m.BackgroundArt.uri = "pkg:/images/bg.jpg"
    end if
End Function

My wild guess is that changing the Uri from within the posterLoadStatus event isn't clearing the previous status?  It also looks like a fail would keep retriggering the same event which is bad.

 

0 Kudos
joetesta
Roku Guru

Re: issue loading image from package

Jump to solution

What happens if you set the uri to the local pkg file initially (ie don't try the failing web link, just using the local jpg), does it work?

aspiring
0 Kudos
rossoneri
Binge Watcher

Re: issue loading image from package

Jump to solution

@joetestathat's a good idea, I went and did that and the pkg image does not work.  The image file is definitely in the zip, and as far as I know that package uri that I posted is correct, so I'm not really sure what to do with this information haha

0 Kudos
cocotower
Roku Guru

Re: issue loading image from package

Jump to solution

Try some things:

Set bg.jpg from within init() to see if it appears, if not the JPG could be bad

Try other image files until one appears, when it appears, move the code back to the event handler to see if it works from there as well?

Verify the directory structure in the zip file...
"components"
"images"
"locale"
"source"
manifest (file)


joetesta
Roku Guru

Re: issue loading image from package

Jump to solution

There are a couple reasons that images will fail to work, one is interlacing.
Like @cocotower suggests try replacing that image with some other existing .png file that you know works, maybe from an example app.  If it does appear, the problem is your image file.  If it does not appear, the problem is something with your folder or view structure or perhaps a typo - anything in debug output?

 

aspiring
rossoneri
Binge Watcher

Re: issue loading image from package

Jump to solution

Thanks for the help, I tried using my splash screen images, which also didn't work, but because of your comments I grabbed a file from one of the example projects on github and that worked.  So I'm guessing you were spot on with interlacing being the issue 

cocotower
Roku Guru

Re: issue loading image from package

Jump to solution

@joetesta wrote:

There are a couple reasons that images will fail to work, one is interlacing.
Like @cocotower suggests try replacing that image with some other existing .png file that you know works, maybe from an example app.  If it does appear, the problem is your image file.  If it does not appear, the problem is something with your folder or view structure or perhaps a typo - anything in debug output?

 


You mean a progressive JPEG?  I've never heard of an interlaced JPEG.  Interlaced, GIF yes.  So far all of my JPEG images work fine.  I typically use the old LVIEW editor for all my work but sometimes make a JPEG using paint.net.  Never had an issue, as I choose 95% or higher quality and standard compression.

joetesta
Roku Guru

Re: issue loading image from package

Jump to solution

tbh I am not a graphics person but I have seen more than one time that a jpg image did not appear on some models (Roku3 especially) of Rokus and the graphics designers had to produce a new version, that to the naked eye appears the same, but to the roku makes all the difference.

aspiring
0 Kudos
rossoneri
Binge Watcher

Re: issue loading image from package

Jump to solution

@cocotower I use gimp for my images and went and looked and "progressive" is a default option for jpegs

0 Kudos