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

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.

Thanks Chris, thats the feedback i was looking for.

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.

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

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

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

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