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

Help with my first channel

Hey all, I got my first Roku in the mail yesterday and once I saw I could make my own private channels, I couldn't resist trying. I made what I thought were some basic changes to the simplevideoplayer source:

' ********************************************************************
' ** Sample PlayVideo App
' ** Copyright (c) 2009 Roku Inc. All Rights Reserved.
' ********************************************************************

Sub Main()
'initialize theme attributes like titles, logos and overhang color
initTheme()

'display a fake screen while the real one initializes. this screen
'has to live for the duration of the whole app to prevent flashing
'back to the roku home screen.
screenFacade = CreateObject("roPosterScreen")
screenFacade.show()

itemVenter = { ContentType:"episode"
SDPosterUrl:"file://pkg:/images/sd.jpg"
HDPosterUrl:"file://pkg:/images/hd.jpg"
IsHD:true
HDBranded:true
ShortDescriptionLine1:"Go Flyers"
ShortDescriptionLine2:""
Description:"Description here"
Rating:"NR"
StarRating:"80"
Length:1972
Categories:["Sports"]
Title:"Go Flyers"
}

showSpringboardScreen(itemVenter)
'showSpringboardScreen(itemMpeg4) 'uncomment this line and comment out the next to see the old mpeg4 example
'showSpringboardScreen(item) 'uncomment this line to see the BigBuckBunny example

'exit the app gently so that the screen doesn't flash to black
screenFacade.showMessage("")
sleep(25)
End Sub

'*************************************************************
'** Set the configurable theme attributes for the application
'**
'** Configure the custom overhang and Logo attributes
'*************************************************************

Sub initTheme()

app = CreateObject("roAppManager")
theme = CreateObject("roAssociativeArray")

theme.OverhangPrimaryLogoOffsetSD_X = "72"
theme.OverhangPrimaryLogoOffsetSD_Y = "15"
theme.OverhangSliceSD = "pkg:/images/Overhang_BackgroundSlice_SD43.png"
theme.OverhangPrimaryLogoSD = "pkg:/images/Logo_Overhang_SD43.png"

theme.OverhangPrimaryLogoOffsetHD_X = "123"
theme.OverhangPrimaryLogoOffsetHD_Y = "20"
theme.OverhangSliceHD = "pkg:/images/Overhang_BackgroundSlice_HD.png"
theme.OverhangPrimaryLogoHD = "pkg:/images/Logo_Overhang_HD.png"

app.SetTheme(theme)

End Sub


'*************************************************************
'** showSpringboardScreen()
'*************************************************************

Function showSpringboardScreen(item as object) As Boolean
port = CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")

print "showSpringboardScreen"

screen.SetMessagePort(port)
screen.AllowUpdates(false)
if item <> invalid and type(item) = "roAssociativeArray"
screen.SetContent(item)
endif

screen.SetDescriptionStyle("generic") 'audio, movie, video, generic
' generic+episode=4x3,
screen.ClearButtons()
screen.AddButton(1,"Play")
screen.AddButton(2,"Go Back")
screen.SetStaticRatingEnabled(false)
screen.AllowUpdates(true)
screen.Show()

downKey=3
selectKey=6
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roSpringboardScreenEvent"
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
if msg.GetIndex() = 1
displayVideo()
else if msg.GetIndex() = 2
return true
endif
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
else
print "wrong type.... type=";msg.GetType(); " msg: "; msg.GetMessage()
endif
end while


return true
End Function


'*************************************************************
'** displayVideo()
'*************************************************************

Function displayVideo()
print "Displaying video: "
p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)

'bitrates = [0] ' 0 = no dots, adaptive bitrate
'bitrates = [348] ' <500 Kbps = 1 dot
'bitrates = [664] ' <800 Kbps = 2 dots
'bitrates = [996] ' <1.1Mbps = 3 dots
'bitrates = [2048] ' >=1.1Mbps = 4 dots
bitrates = [0]

'Swap the commented values below to play different video clips...
'urls = ["http://video.ted.com/talks/podcast/CraigVenter_2008_480.mp4"]
'qualities = ["HD"]
'StreamFormat = "mp4"
'title = "Craig Venter Synthetic Life"
'srt = "file://pkg:/source/craigventer.srt"

'urls = ["http://video.ted.com/talks/podcast/DanGilbert_2004_480.mp4"]
'qualities = ["HD"]
'StreamFormat = "mp4"
'title = "Dan Gilbert asks, Why are we happy?"

' Apple's HLS test stream
urls = ["http://someHost/myPlaylist.m3u8"] ' The playlist plays in VLC 1.2.0
qualities = ["HD"]
streamformat = "hls"
title = "Go Flyers"

' Big Buck Bunny test stream from Wowza
'urls = ["http://ec2-174-129-153-104.compute-1.amazonaws.com:1935/vod/smil:BigBuckBunny.smil/playlist.m3u8"]
'qualities = ["SD"]
'streamformat = "hls"
'title = "Big Buck Bunny"

videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = bitrates
videoclip.StreamUrls = urls
videoclip.StreamQualities = qualities
videoclip.StreamFormat = streamformat
videoclip.Title = title
'print "srt = ";srt
'if srt <> invalid and srt <> "" then
' videoclip.SubtitleUrl = srt
'end if

video.SetContent(videoclip)
video.show()

lastSavedPos = 0
statusInterval = 10 'position must change by more than this number of seconds before saving

while true
msg = wait(0, video.GetMessagePort())
if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed() then 'ScreenClosed event
print "Closing video screen"
exit while
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
if nowpos > 10000

end if
if nowpos > 0
if abs(nowpos - lastSavedPos) > statusInterval
lastSavedPos = nowpos
end if
end if
else if msg.isRequestFailed()
print "play failed: "; msg.GetMessage()
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
end if
end while
End Function


But for some reason playback doesn't work (the playlist will playback correctly using VLC's HLS module). Here's the output
------ Running ------
showSpringboardScreen
Button pressed: 1 0
Displaying video:
Unknown event: 20 msg:
play failed: An unexpected problem (but not server timeout or HTTP error) has been detected.
Closing video screen
^CBrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
100: Function showSpringboardScreen(item as object) As Boolean
101: port = CreateObject("roMessagePort")
102: screen = CreateObject("roSpringboardScreen")
103:
104: print "showSpringboardScreen"
105:
106: screen.SetMessagePort(port)
107: screen.AllowUpdates(false)
108: if item <> invalid and type(item) = "roAssociativeArray"
109: screen.SetContent(item)
110: endif
111:
112: screen.SetDescriptionStyle("generic") 'audio, movie, video, generic
113: ' generic+episode=4x3,
114: screen.ClearButtons()
115: screen.AddButton(1,"Play")
116: screen.AddButton(2,"Go Back")
117: screen.SetStaticRatingEnabled(false)
118: screen.AllowUpdates(true)
119: screen.Show()
120:
121: downKey=3
122: selectKey=6
123: while true
124: msg = wait(0, screen.GetMessagePort())
125: if type(msg) = "roSpringboardScreenEvent"
126: if msg.isScreenClosed()
127: print "Screen closed"
128: exit while
129: else if msg.isButtonPressed()
130: print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
131: if msg.GetIndex() = 1
132: displayVideo()
133: else if msg.GetIndex() = 2
134: return true
135: endif
136: else
137: print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
138: endif
139: else
140: print "wrong type.... type=";msg.GetType(); " msg: "; msg.GetMessage()
141: endif
142: end while
143:
144:
145: return true
146: End Function
Break in 124
124: msg = wait(0, screen.GetMessagePort())

Backtrace:
Function showspringboardscreen(item As Object) As Boolean
Function main() As Void

Local Variables:
item &h16 bsc:roAssociativeArray, refcnt=2
global &h07 rotINTERFACE:ifGlobal
m &h06 bsc:roAssociativeArray, refcnt=3
port &h16 bsc:roMessagePort, refcnt=2
screen &h16 bsc:roSpringboardScreen, refcnt=1
downkey &h12 Integer val:3
selectkey &h12 Integer val:6
msg &h16 bsc:roSpringboardScreenEvent, refcnt=1
BrightScript Debugger> BrightScript Debugger>
Current Function:
100: Function showSpringboardScreen(item as object) As Boolean
101: port = CreateObject("roMessagePort")
102: screen = CreateObject("roSpringboardScreen")
103:
104: print "showSpringboardScreen"
105:
106: screen.SetMessagePort(port)
107: screen.AllowUpdates(false)
108: if item <> invalid and type(item) = "roAssociativeArray"
109: screen.SetContent(item)
110: endif
111:
112: screen.SetDescriptionStyle("generic") 'audio, movie, video, generic
113: ' generic+episode=4x3,
114: screen.ClearButtons()
115: screen.AddButton(1,"Play")
116: screen.AddButton(2,"Go Back")
117: screen.SetStaticRatingEnabled(false)
118: screen.AllowUpdates(true)
119: screen.Show()
120:
121: downKey=3
122: selectKey=6
123: while true
124: msg = wait(0, screen.GetMessagePort())
125: if type(msg) = "roSpringboardScreenEvent"
126: if msg.isScreenClosed()
127: print "Screen closed"
128: exit while
129: else if msg.isButtonPressed()
130: print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
131: if msg.GetIndex() = 1
132: displayVideo()
133: else if msg.GetIndex() = 2
134: return true
135: endif
136: else
137: print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
138: endif
139: else
140: print "wrong type.... type=";msg.GetType(); " msg: "; msg.GetMessage()
141: endif
142: end while
143:
144:
145: return true
146: End Function
/tmp/plugin/LDAAAAcK5OCc/pkg:/source/appMain.brs(140): runtime error ec: 'Dot' Operator attempted with invalid BrightScript Component or interface reference.

140: print "wrong type.... type=";msg.GetType(); " msg: "; msg.GetMessage()

Backtrace:
Function showspringboardscreen(item As Object) As Boolean
Function main() As Void

Local Variables:
item &h16 bsc:roAssociativeArray, refcnt=2
global &h07 rotINTERFACE:ifGlobal
m &h06 bsc:roAssociativeArray, refcnt=3
port &h16 bsc:roMessagePort, refcnt=2
screen &h16 bsc:roSpringboardScreen, refcnt=1
downkey &h12 Integer val:3
selectkey &h12 Integer val:6
msg &h1a Invalid val:invalid


Thanks so much for taking the time to look at this and explaining what I'm guessing is a pretty noob-y mistake 🙂
0 Kudos
2 REPLIES 2
stratcat96
Visitor

Re: Help with my first channel

try adding this line to your videoclip parameters, as possibly the bandwidth may be less than the threshhold of 250k.I've seen the same debug message when that as the case. If less than 250k, the Roku will ignore it so by telling it to specifically look for a lower bandwidth and higher, you can override that behavior.

videoclip.minBandwidth = 20
0 Kudos
rlutz
Visitor

Re: Help with my first channel

Looks like it's just an issue with that particular playlist. I tried another one and it worked. Thanks for the help!
0 Kudos