Forum Discussion
RokuChris
16 years agoRoku Employee
If you're dealing with audio or video, the flickr example is probably not the best one to be working from. The audioapp and simplevideoplayer examples may be more helpful. The steps you outline are very common tasks for almost any channel. This code would work for video content. Audio would be handled differently using roAudioPlayer.
' 1. send a request to an api service with a user code
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://api.something.com/category?=consumercode=myappsconsumercode")
xferResult = xfer.GetToString()
' 2. parse the xml that is returned from that request for a particular key containing a URL
xml = CreateObject("roXMLElement")
if xml.Parse(xferResult)
contentURL = xml.contentURL.GetText() ' this line will change based on the structure of your XML
end if
' 4. call an audio or video player to play that URL (this might be one and the same as #3)
screen = CreateObject("roVideoScreen")
screen.SetMessagePort(CreateObject("roMessagePort"))
screen.SetContent({
stream: {
url: contentURL
}
streamFormat: "mp4"
})
screen.Show()
while true
msg = wait(0, screen.GetMessagePort())
if msg <> invalid
if msg.isScreenClosed()
exit while
end if
end if
end while