Thank you for the response. I have used roScreen for doing this. Here is the code that I have worked on until now but I face an issue below:
Interface not a member of BrightScript Component (runtime error &hf3) in pkg:/so
urce/HTTPSample.brs(155)
155: m.region.SetWrap(true)
This error comes after I download 10 images and start animating them one after the other. It throws this error after 8 images are displayed. Can you help?
Library "v30/bslCore.brs"
Function main()
black=&hFF'RGBA
m.screen=CreateObject("roScreen")
m.compositor=CreateObject("roCompositor")
m.compositor.SetDrawTo(m.screen, black)
m.http = CreateObject("roUrlTransfer")
m.http.SetMessagePort(CreateObject("roMessagePort"))
getOverlays()
DownloadOverlays()
m.k = 0
m.mylocal= []
showOverlays()
End Function
Function DownloadOverlays()
'm.arr = CreateObject("roAssociativeArray")
m.myarray = []
i=0
'print "**********download url list**********"; m.overlays.response.tiles_overlays
for each uri in m.overlays.response.tiles_overlays
print "****download url**** "; uri.overlay_url
m.myarray[i]= uri.overlay_url
print "**Umesh Array** =" m.myarray[i]
i=i+1
end for
End Function
Function getOverlays()
port = CreateObject("roMessagePort")
m.http.SetMessagePort(port)
'url = "URL_TO_GET_OVERLAYS"
url = "http://data.weathernationtv.com/services/sonyvita/maps/tileoverlays?method_type=2¢er_lat=39.7392¢er_lng=-104.9847&width=1280&height=720&type_code=radar&zoomlevel=5"
'url = "http://54.241.13.70/services/roku/maps/tileoverlays?method_type=2¢er_lat=" + Str(m.lat).trim() +"¢er_lng=" + Str(m.lng).trim() +"&width="+(m.mapWidth).toStr()+"&height="+(m.mapHeight).toStr()+"&type_code="+m.selectedOverlay+"&zoomlevel=" + m.zoom.toStr()
print "url=> "; url
m.http.SetUrl(url)
if (m.http.AsyncGetToString())
'**Begin a GET request to a string asynchronously. When the GET completes, an roUrlEvent will be sent to the message port associated with the object
While (true)
msg = wait(0, port)
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
print"**code**"; code
if (code = 200)
m.overlays = parseJSON(msg.GetString())
print "***OVERLAY**"; formatJSON(m.overlays)
exit while
else
print "Error Code: "; code
exit while
end if
end if
end while
end if
End Function
Function showOverlays()
print"store in tmp**************"
for each url in m.myarray
m.http.SetUrl(url)
print url m.k
m.k = m.k+1
index = "tmp:/VeryBigPng"+(m.k).tostr()+".png"
m.mylocal[m.k-1]= index
m.http.AsyncGetToFile(index)
wait(0, m.http.GetPort())
if m.k = 10
m.k =0
Animate()
end If
end for
'm.http.SetUrl(m.myarray[m.k])
'm.k = m.k+1
'index = "tmp:/VeryBigPng"+(m.k).tostr()+".png"
'm.mylocal[m.k-1]= index
'm.http.AsyncGetToFile(index)
'wait(0, m.http.GetPort())
'if m.k = 9
'm.k =0
'Animate()
'end If
'm.bigbm=CreateObject("roBitmap",index)
'm.region=CreateObject("roRegion", m.bigbm, 0, 0, 1280, 1280)
'm.region.SetWrap(true)
'view_sprite=m.compositor.NewSprite(0, 0, m.region)
'm.compositor.draw()
'm.screen.SwapBuffers()
m.msgport = CreateObject("roMessagePort")
m.screen.SetMessagePort(m.msgport)
codes = bslUniversalControlEventCodes()
'm.n = 1
While True
msg=wait(0, m.msgport) ' wait for a button
print "Msg: "; type(msg); " event: "; msg.GetInt()
If type(msg)="roUniversalControlEvent" Then
If msg.GetInt()=codes.BUTTON_UP_PRESSED Then
'm.http.SetUrl(m.myarray[m.k])
'm.k = m.k + 1
showOverlays()
Else If msg.GetInt()=codes.BUTTON_DOWN_PRESSED Then
Zip(m.screen, view_sprite, m.compositor, 0,+4) ' down
Else If msg.GetInt()=codes.BUTTON_RIGHT_PRESSED Then
Zip(m.screen, view_sprite, m.compositor, +4,0) ' right
Else If msg.GetInt()=codes.BUTTON_LEFT_PRESSED Then
Zip(m.screen, view_sprite, m.compositor, -4, 0) ' left
Else If msg.GetInt() = codes.BUTTON_BACK_PRESSED ' back button
Exit While
End If
else
print "image changed"
if(m.index = m.overlays.response.tiles_overlays.count()-1)
m.index = 0
else
m.index = m.index+1
end if
End If
'End If
End While
End Function
Function Animate()
for j=0 to 10 step 1
sleep(2000)
print"under animate***********"
print "url in animate" m.mylocal[j]
m.bigbm=CreateObject("roBitmap",m.mylocal[j])
m.region=CreateObject("roRegion", m.bigbm, 0, 0, 1280, 1280)
m.region.SetWrap(false)
view_sprite=m.compositor.NewSprite(0, 0, m.region)
m.compositor.draw()
m.screen.SwapBuffers()
m.msgport = CreateObject("roMessagePort")
m.screen.SetMessagePort(m.msgport)
end For
End Function