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: 
EngoTom
Visitor

Media not found event?

I have a scenario where if a media item is not found at its location use a backup media location.
I'd like to do this through a media load method with a timeout property and an event that is raised if it’s not found.
Is this available? If not is there a recommended approach?

THX

Tom
0 Kudos
2 REPLIES 2
RokuKevin
Visitor

Re: Media not found event?

We don't have an auto-retry to a different media location.....

I suggest you code it in your app. You can check the media url first with roUrlTransfer and if it doesn't exist use the backup media location. You can use the Range: header in your request to check existence of URL without downloading a lot of data.



Function isUrlValid(url As String) As Boolean
urlValid = false
http = CreateObject("roUrlTransfer")
http.SetPort(CreateObject("roMessagePort"))
http.SetUrl(url)
http.AddHeader("Range","bytes=0-15")
if (http.AsyncGetToString())
event = wait(5000, http.GetPort())
if type(event) = "roUrlEvent"
if (event.GetResponseCode() >= 200 and event.GetResponseCode() < 300) then
response = event.GetString()
print "response: "; response
urlValid = true
end if
elseif event = invalid
http.AsyncCancel()
else
http.AsyncCancel()
endif
endif

return urlValid

End Function



--Kevin
0 Kudos
EngoTom
Visitor

Re: Media not found event?

Thanks, Just what I needed.
0 Kudos