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

MAKING A VIDEO PLAYER

Ok so i used the simple video player as a base for my project and just changed the values to MY video i wanted to play and then changed the link to my actual video link. \Everything looks fine on the screen but the video wont play. heres what i get in the debug screen through telnet:
------ Running ------
Type args = roAssociativeArray
Type args.url = Invalid
showSpringboardScreen
Button pressed: 1 0
Displaying video:
srt = <UNINITIALIZED>
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
161: Function displayVideo(args As Dynamic)
162: print "Displaying video: "
163: p = CreateObject("roMessagePort")
164: video = CreateObject("roVideoScreen")
165: video.setMessagePort(p)
166:
167: 'bitrates = [0] ' 0 = no dots, adaptive bitrate
168: bitrates = [348] ' <500 Kbps = 1 dot
169: bitrates = [664] ' <800 Kbps = 2 dots
170: bitrates = [996] ' <1.1Mbps = 3 dots
171: bitrates = [2048] ' >=1.1Mbps = 4 dots
172: 'bitrates = [0]
173:
174: 'Swap the commented values below to play different video clips...
175: urls = ["192.168.1.101/VIDEO/In_Time.mp4"]
176: qualities = ["HD"]
177: StreamFormat = "mp4"
178: title = "I Love You"
179:
180: 'urls = ["http://video.ted.com/talks/podcast/DanGilbert_2004_480.mp4"]
181: 'qualities = ["HD"]
182: 'StreamFormat = "mp4"
183: 'title = "Dan Gilbert asks, Why are we happy?"
184:
185: ' Apple's HLS test stream
186: 'urls = ["http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3
u8"]
187: 'qualities = ["SD"]
188: 'streamformat = "hls"
189: 'title = "Apple BipBop Test Stream"
190:
191: ' Big Buck Bunny test stream from Wowza
192: 'urls = ["http://ec2-174-129-153-104.compute-1.amazonaws.com:1935/vod/s
mil:BigBuckBunny.smil/playlist.m3u8"]
193: 'qualities = ["SD"]
194: 'streamformat = "hls"
195: 'title = "Big Buck Bunny"
196:
197: if type(args) = "roAssociativeArray"
198: if type(args.url) = "roString" and args.url <> "" then
199: urls[0] = args.url
200: end if
201: if type(args.StreamFormat) = "roString" and args.StreamFormat <> ""
then
202: StreamFormat = args.StreamFormat
203: end if
204: if type(args.title) = "roString" and args.title <> "" then
205: title = args.title
206: else
207: title = ""
208: end if
209: if type(args.srt) = "roString" and args.srt <> "" then
210: srt = args.StreamFormat
211: else
212: srt = ""
213: end if
214: end if
215:
216: videoclip = CreateObject("roAssociativeArray")
217: videoclip.StreamBitrates = bitrates
218: videoclip.StreamUrls = urls
219: videoclip.StreamQualities = qualities
220: videoclip.StreamFormat = StreamFormat
221: videoclip.Title = title
222: print "srt = ";srt
223: if srt <> invalid and srt <> "" then
224: videoclip.SubtitleUrl = srt
225: end if
226:
227: video.SetContent(videoclip)
228: video.show()
229:
230: lastSavedPos = 0
231: statusInterval = 10 'position must change by more than this number of s
econds before saving
232:
233: while true
234: msg = wait(0, video.GetMessagePort())
235: if type(msg) = "roVideoScreenEvent"
236: if msg.isScreenClosed() then 'ScreenClosed event
237: print "Closing video screen"
238: exit while
239: else if msg.isPlaybackPosition() then
240: nowpos = msg.GetIndex()
241: if nowpos > 10000
242:
243: end if
244: if nowpos > 0
245: if abs(nowpos - lastSavedPos) > statusInterval
246: lastSavedPos = nowpos
247: end if
248: end if
249: else if msg.isRequestFailed()
250: print "play failed: "; msg.GetMessage()
251: else
252: print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMe
ssage()
253: endif
254: end if
255: end while
256: End Function
Use of uninitialized variable. (runtime error &he9) in ...WEbCu/pkg:/source/appM
ain.brs(223)

223: if srt <> invalid and srt <> "" then
Backtrace:
Function displayvideo(args As ) As
file/line: /tmp/plugin/PEAA...WEbCu/pkg:/source/appMain.brs(223)
Function showspringboardscreen(item As <uninitialized>) As Boolean
file/line: /tmp/plugin/PEAA...WEbCu/pkg:/source/appMain.brs(140)
Function main(args As ) As
file/line: /tmp/plugin/PEAA...WEbCu/pkg:/source/appMain.brs(66)

Local Variables:
args &h0100 String (VT_STR_CONST) val:
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=4
p &h0010 bsc:roMessagePort, refcnt=2
video &h0010 bsc:roVideoScreen, refcnt=1
bitrates &h0010 bsc:roArray, refcnt=2
urls &h0010 bsc:roArray, refcnt=2
qualities &h0010 bsc:roArray, refcnt=2
streamformat &h0100 String (VT_STR_CONST) val:mp4
title &h0100 String (VT_STR_CONST) val:I Love You
srt &h0000 <uninitialized> val:Uninitialized
videoclip &h0010 bsc:roAssociativeArray, refcnt=1
lastsavedpos &h0000 <uninitialized> val:Uninitialized
statusinterval &h0000 <uninitialized> val:Uninitialized
msg &h0000 <uninitialized> val:Uninitialized
nowpos &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger>



And heres my appMain file: (ignore the i love you text. It was a joke because my GF was on the Roku box playing a movie when i installed it and i wanted to mess with her)
' ********************************************************************
' ** Sample PlayVideo App
' ** Copyright (c) 2009 Roku Inc. All Rights Reserved.
' ********************************************************************

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

if type(args) = "roAssociativeArray" and type(args.url) = "roString" then
displayVideo(args)
end if
print "Type args = "; type(args)
print "Type args.url = "; type(args.url)

'has to live for the duration of the whole app to prevent flashing
'back to the roku home screen.
screenFacade = CreateObject("roPosterScreen")
screenFacade.show()

itemMpeg4 = { ContentType:"episode"
SDPosterUrl:"file://pkg:/images/DanGilbert.jpg"
HDPosterUrl:"file://pkg:/images/DanGilbert.jpg"
IsHD:False
HDBranded:False
ShortDescriptionLine1:"Dan Gilbert asks, Why are we happy?"
ShortDescriptionLine2:""
Description:"Harvard psychologist Dan Gilbert says our beliefs about what will make us happy are often wrong -- a premise he supports with intriguing research, and explains in his accessible and unexpectedly funny book, Stumbling on Happiness."
Rating:"NR"
StarRating:"80"
Length:1280
Categories:["Technology","Talk"]
Title:"Dan Gilbert asks, Why are we happy?"
}

itemVenter = { ContentType:"episode"
SDPosterUrl:"file://pkg:/images/CraigVenter-2008.jpg"
HDPosterUrl:"file://pkg:/images/CraigVenter-2008.jpg"
IsHD:False
HDBranded:False
ShortDescriptionLine1:"HI CHARLEE"
ShortDescriptionLine2:""
Description:"Hey charlee If your reading this I love you, and id give you all my time. you are my world. I love you so much!"
Rating:"<3"
StarRating:"I ❤️ U"
Length:1560
Categories:["Technology","Talk"]
Title:"I Love You"
}

item = { ContentType:"episode"
SDPosterUrl:"file://pkg:/images/BigBuckBunny.jpg"
HDPosterUrl:"file://pkg:/images/BigBuckBunny.jpg"
IsHD:true
HDBranded:true
ShortDescriptionLine1:"Big Buck Bunny"
ShortDescriptionLine2:""
Description:"Big Buck Bunny is being served using a Wowza server running on Amazon EC2 cloud services. The video is transported via HLS HTTP Live Streaming. A team of small artists from the Blender community produced this open source content..."
Rating:"NR"
StarRating:"80"
Length:600
Categories:["Technology","Cartoon"]
Title:"Big Buck Bunny"
}

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"

'this is an optional theme attribute. the default subtitle color is yellow.
theme.SubtitleColor = "#dc00dc"

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(args As Dynamic)
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 = ["192.168.1.101/VIDEO/In_Time.mp4"]
qualities = ["HD"]
StreamFormat = "mp4"
title = "I Love You"

'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://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]
'qualities = ["SD"]
'streamformat = "hls"
'title = "Apple BipBop Test Stream"

' 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"

if type(args) = "roAssociativeArray"
if type(args.url) = "roString" and args.url <> "" then
urls[0] = args.url
end if
if type(args.StreamFormat) = "roString" and args.StreamFormat <> "" then
StreamFormat = args.StreamFormat
end if
if type(args.title) = "roString" and args.title <> "" then
title = args.title
else
title = ""
end if
if type(args.srt) = "roString" and args.srt <> "" then
srt = args.StreamFormat
else
srt = ""
end if
end if

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




Please help. Ive spent hours trying to figure this out. it seems like i fix one error and get another! Ive got this far now i dont know how to fix this haha
0 Kudos
8 REPLIES 8
Kenwhit23
Visitor

Re: MAKING A VIDEO PLAYER

BTW Im making this for my classic ROKU XD its not a ROKU 2
0 Kudos
Kenwhit23
Visitor

Re: MAKING A VIDEO PLAYER

Ok so i fixed the probelm i needed to add the line srt = ""

But now it goes to load and i get this?
any ideas how to fix it???:
------ Running ------
Type args = roAssociativeArray
Type args.url = Invalid
showSpringboardScreen
Button pressed: 1 0
Displaying video:
srt =
play failed: The connection timed out.
Closing video screen
0 Kudos
belltown
Roku Guru

Re: MAKING A VIDEO PLAYER

Change:

urls = ["192.168.1.101/VIDEO/In_Time.mp4"]


To:

urls = ["http://192.168.1.101/VIDEO/In_Time.mp4"]


and double-check you have the correct URL/path, etc. and your server is running.
0 Kudos
Kenwhit23
Visitor

Re: MAKING A VIDEO PLAYER

Ok i changed it but now i get this error:

------ Running ------
Type args = roAssociativeArray
Type args.url = Invalid
showSpringboardScreen
Button pressed: 1 0
Displaying video:
srt =
play failed: An unexpected problem (but not server timeout or HTTP error) has be
en detected.
Closing video screen
Button pressed: 1 0
Displaying video:
srt =
play failed: An unexpected problem (but not server timeout or HTTP error) has be
en detected.
Closing video screen
Screen closed


I know the video works because it loads when i use roksbox.... Im at a loss for what to do
0 Kudos
belltown
Roku Guru

Re: MAKING A VIDEO PLAYER

Do the other videos in the code work when you un-comment them?

And do you get the same result if you change:

qualities = ["HD"]


To:

qualities = ["SD"]
0 Kudos
Kenwhit23
Visitor

Re: MAKING A VIDEO PLAYER

Ok so after fiddling with it and double checking using roksbox to make sure the video worked it turned out to be the video itself. It wasnt properly formated to play on the roku box. I swapped it out with a different video and it works perfectly. So now from here i need to figure out how to make a main screen so i can have more than one video. and be able to select by genre.... any good tutorials or suggestions?
0 Kudos
bandal
Visitor

Re: MAKING A VIDEO PLAYER

The videoplayer sample versus the simplevideo is much better for what you are now asking.
DA
0 Kudos
Kenwhit23
Visitor

Re: MAKING A VIDEO PLAYER

I am trying to use the video player but i dont quite understand how to get it to work... I have changed a few things in the xml to my videos yet its still playing like i didnt make the changes even though i changed the links to my video....
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.