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

Add trailer link button

I hope I'm not being annoying with my posts. I'm really catching on to the how Roku works, but I'm still new to it.

Anyone know how to add a how to link a button on the springboard to a trailer (not the built-in 2 min preview, a totally different video)?

Thank you in advance!
0 Kudos
9 REPLIES 9
stitch1z
Visitor

Re: Add trailer link button

Curious if I am on the right track...


if msg.GetIndex() = 7
item.StreamUrls.Push(validstr(e.preview.GetText()))
endif
0 Kudos
stitch1z
Visitor

Re: Add trailer link button

Still struggling with this.

I am using the videoplayer example as a source.

I have defined the <trailer> in my xml, but I have no idea how to parse this and play it when someone hits button "7". Do I put all of the code in appDetailScreen.brs or do I parse it in Showfeed.brs and somehow refer to it in appDetailScreen?

Do I use the showVideoScreen or not? Ugh. This is kicking my butt. lol
0 Kudos
stitch1z
Visitor

Re: Add trailer link button

I realize that I am talking to myself for the mostpart, but just in case any of you frighteningly intelligent folks wish to chime in, I'm trying this now, which I would think should be on the right track... ?

if msg.GetIndex() = 7
Function showVideoScreen(movie As Object)
screen = CreateObject("roVideoScreen")
movie.Stream = { url:"http://video.ted.com/talks/podcast/ElizabethGilbert_2009_480.mp4",
contentid:"mycontent-2000"
}
screen.SetContent(movie)
screen.SetMessagePort(port)
screen.Show()
End Function
endif

Obviously, I wouldn't use the actual url in the brightscript like that, but at this point I am trying to isolate where I am going wrong. Once I get the function to work with a hardcoded url in the brightscript, I will tackle parsing it from an xml file.

What's funny is that I am having this much difficulty simply trying to communicate to the Roku:
"IF I press button '7', play this file." And I am too dopey to work that out. Sheesh!
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: Add trailer link button

You don't need to redefine the function within the event loop. That will probably give you an error on install along the lines of "function defined multiple times". You can reuse the existing one. And changing the stream URL of the existing content-meta-data is an option, but it might make more sense to build a separate content-meta-data for the trailer.

if msg.GetIndex() = 7
trailer = {
stream: { url:"http://video.ted.com/talks/podcast/ElizabethGilbert_2009_480.mp4" }
streamFormat: "mp4"
}
ShowVideoScreen(trailer)
end if
0 Kudos
stitch1z
Visitor

Re: Add trailer link button

"RokuChris" wrote:
You don't need to redefine the function within the event loop. That will probably give you an error on install along the lines of "function defined multiple times". You can reuse the existing one. And changing the stream URL of the existing content-meta-data is an option, but it might make more sense to build a separate content-meta-data for the trailer.

Thank you SOOOO much, Chris! That works!

Do to parse this from xml, it would look something like this?
if msg.GetIndex() = 7
trailer = {
stream: { item.trailer.GetText() }
streamFormat: "mp4"
}
ShowVideoScreen(trailer)
endif


I know this doesn't function properly because I tested it, but I again, just trying to figure out if I am on the right track.

The XML structure is:
<feed>
<item>
<trailer>

Thank you again! So appreciated!
0 Kudos
stitch1z
Visitor

Re: Add trailer link button

Still struggling through this. I just can't figure out the language to make it happen...

Any input is highly appreciated! 😄
0 Kudos
stitch1z
Visitor

Re: Add trailer link button

So would I even call "stream"?

Or would I define this in the showfeed.brs?

And if so, would it be like:

item.StreamUrls = item.trailer


I'm just so confused about this...
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: Add trailer link button

"stitch1z" wrote:
if msg.GetIndex() = 7
trailer = {
stream: { item.trailer.GetText() }
streamFormat: "mp4"
}
ShowVideoScreen(trailer)
endif


Your XML structure is out of scope here, so the variable item doesn't exist at this point in the code. You need to extract those values at the same time you're extracting all the other data from your XML. The easiest thing to do is to just build the trailer's content-meta-data in the parsing routine and store it as an attribute of the main content-meta-data. So you would add something like this to your parsing logic...

item.trailer = {
stream: { url: validstr(curShow.trailer.GetText()) }
streamFormat: "mp4"
}


Then you can eliminate that logic from the springboard code and just play the trailer you already built...

if msg.GetIndex() = 7
ShowVideoScreen(showList[showIndex].trailer)
end if
0 Kudos
stitch1z
Visitor

Re: Add trailer link button

WORKED!

You are amazing! I really appreciate the patience.

I have some coding experience, but I learn a lot better through step-by-step tutorials. The SDK documentation is abundant, but just reading "x works with y which could also be combined with z to create b" is really tough for a dummy like me to wrap my head around.

Again, I really appreciate the help and your patience. I hope this thread will help another noob someday.
0 Kudos