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: 
squirreltown
Roku Guru

URL Transfer

I'm grabbing a bunch of graphics when my channel loads. Is this the best way to do it or is there a more efficient or faster way?
thanks

Function GetAlbumArt()

AT = CreateObject("roUrlTransfer")
AT.SetUrl("http://www.xxxx.com/roku/url/albumcover_hd.png")
AT.GetToFile("tmp:/albumcover_hd.png")
AT2 = CreateObject("roUrlTransfer")
AT2.SetUrl("http://www.xxxx.com/roku/url/albumcover2_hd.png")
AT2.GetToFile("tmp:/albumcover2_hd.png")
AT3 = CreateObject("roUrlTransfer")
AT3.SetUrl("http://www.xxxx.com/roku/url/albumcover3_hd.png")
AT3.GetToFile("tmp:/albumcover3_hd.png")
AT4 = CreateObject("roUrlTransfer")
AT4.SetUrl("http://www.xxxx.com/roku/url/albumcover4_hd.png")
AT4.GetToFile("tmp:/albumcover4_hd.png")
AT5 = CreateObject("roUrlTransfer")
AT5.SetUrl("http://www.xxxx.com/roku/url/screensaver.png")
AT5.GetToFile("tmp:/screensaver.png")

End Function
Kinetics Screensavers
0 Kudos
7 REPLIES 7
RokuChris
Roku Employee
Roku Employee

Re: URL Transfer

To improve launch time, you could...



FYI: When you do a series of downloads synchronously the way you are now, there's no need to create a new roURLTansfer for each one. That won't speed things up much, but calls to CreateObject() are fairly expensive.
0 Kudos
squirreltown
Roku Guru

Re: URL Transfer

Thanks Chris, thats the feedback i was looking for.
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: URL Transfer

Ok so whats the format for doing multiple downloads with the same transfer object? The function below gets the first graphic but not the second.
AT = CreateObject("roUrlTransfer")
aport = CreateObject("roMessagePort")
AT.setmessageport(aport)
AT.SetUrl("http://www.xxxx.com/roku/url/albumcover_hd.png")
AT.AsyncGetToFile("tmp:/albumcover_hd.png")
AT.SetUrl("http://www.xxxx.com/roku/url/albumcover2_hd.png")
AT.AsyncGetToFile("tmp:/albumcover2_hd.png")


I tried it with commas in between setURL( x,x,x) but no-go.
Kinetics Screensavers
0 Kudos
TheEndless
Channel Surfer

Re: URL Transfer

"squirreltown" wrote:
Ok so whats the format for doing multiple downloads with the same transfer object? The function below gets the first graphic but not the second.
AT = CreateObject("roUrlTransfer")
aport = CreateObject("roMessagePort")
AT.setmessageport(aport)
AT.SetUrl("http://www.xxxx.com/roku/url/albumcover_hd.png")
AT.AsyncGetToFile("tmp:/albumcover_hd.png")
AT.SetUrl("http://www.xxxx.com/roku/url/albumcover2_hd.png")
AT.AsyncGetToFile("tmp:/albumcover2_hd.png")


I tried it with commas in between setURL( x,x,x) but no-go.

For asynchronous, you need to create new components for each like you were in your original. For synchronous, you can reuse the same component, because the call will block until the download completes.
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
squirreltown
Roku Guru

Re: URL Transfer

Thanks TheEndless, So I suppose Async is still preferred, even with separate transfer objects since it doesn't prevent anything else from happening?
Kinetics Screensavers
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: URL Transfer

"squirreltown" wrote:
Thanks TheEndless, So I suppose Async is still preferred, even with separate transfer objects since it doesn't prevent anything else from happening?


Yes, making the requests asynchronous will save much more time than you will incur by creating the additional objects.
0 Kudos
RokuJoel
Binge Watcher

Re: URL Transfer

If you want to keep track of which transfer is associated with which object, you can use the ifURLTransfer.GetIdentity() and ifURLEvent.GetSourceIdentity() to track the status of each request.

- Joel
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.