Your Digital Media Has Never Looked So Good

 
jbrave
Topic Author
Posts: 716
Joined: Mon Mar 22, 2010 3:00 pm
Location: Ben Lomond, CA
Contact:

need a little help with brightscript

Mon Sep 06, 2010 5:44 pm

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!
 
User avatar
RokuChris
Posts: 1166
Joined: Mon Aug 30, 2010 1:45 pm

Re: need a little help with brightscript

Mon Sep 06, 2010 6:52 pm

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
 
jbrave
Topic Author
Posts: 716
Joined: Mon Mar 22, 2010 3:00 pm
Location: Ben Lomond, CA
Contact:

Re: need a little help with brightscript

Mon Sep 06, 2010 6:59 pm

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!

Who is online

Users browsing this forum: No registered users and 10 guests