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: 
jbrave
Channel Surfer

need a little help with brightscript

Any suggestions on how to get started with Bright Script? I've been hacking around for a week or so and trying to figure out how to do a one-shot program:

1. send a request to an api service with a user code (http://api.something.com/category?=cons ... nsumercode
2. parse the xml that is returned from that request for a particular key containing a URL
3. issue an http request for that URL
4. call an audio or video player to play that URL (this might be one and the same as #3)
5. exit.

I've been trying to hack the flickr example to figure this out, but I just don't know enough. If anyone would be so kind as to point me to , or post a good example of how to do this in a short program?

I'm sort of a hybrid newbie and experienced person at programming - my background in LotusScript (said to be kinda like Visual Basic) programming gives me some help in reading the example Brightscripts, but I would like to see some examples, even one-liners of each of the above types of internet communication.

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
2 REPLIES 2
RokuChris
Roku Employee
Roku Employee

Re: need a little help with brightscript

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
0 Kudos
jbrave
Channel Surfer

Re: need a little help with brightscript

Ahh, thank you so much! My brain feels better now.
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos