Joel,
Thanks for clarifying the debugging thing.
In regards for the auto restart that we are trying to get working. There is something definitely not right with the script that you have helped us develop.
Here is what the code is:
' ********************************************************************
' ** 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()
item = { ContentType:"episode"
SDPosterUrl:"file://pkg:/images/BigBuckBunny.jpg"
HDPosterUrl:"file://pkg:/images/BigBuckBunny.jpg"
IsHD:false
HDBranded:true
ShortDescriptionLine1:"The Music Channel"
ShortDescriptionLine2:""
Description:"Playing the best in Southern Gospel and Christian Country Music, 24 hours a day!"
Rating:"NR"
StarRating:"80"
'Length:999999999
Categories:["Music","Religious"]
Title:"Family Friendly Entertainment"
}
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 Live Stream")
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
returnvalue=-5
while returnvalue=-5
returnvalue=displayVideo("")
end while
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 = [1500] ' >=1.1Mbps = 4 dots
'bitrates = [0]
'Swap the commented values below to play different video clips...
' Stream Info
urls = ["http://kitiosdevices-i.akamaihd.net/hls/live/202237/FFE_Roku/iOS/playlist.m3u8"]
qualities = ["SD"]
streamformat = "hls"
title = "The Music Channel"
srt = "file://pkg:/source/craigventer.srt"
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 message.isrequestfailed()
return -5
else if message.isfullresult()
return -1
end if
end if
end while
End Function
Here is what the debugger is giving us:
*** ERROR compiling /pkg:/source/appMain.brs:
Syntax Error. (compile error &h02) in ...4pfNw/pkg:/source/appMain.brs(21)
Syntax Error. (compile error &h02) in ...4pfNw/pkg:/source/appMain.brs(23)
Syntax Error. (compile error &h02) in ...4pfNw/pkg:/source/appMain.brs(24)
Syntax Error. (compile error &h02) in ...4pfNw/pkg:/source/appMain.brs(25)
Syntax Error. (compile error &h02) in ...4pfNw/pkg:/source/appMain.brs(26)
------ Running ------
Type args = roAssociativeArray
Type args.url = Invalid
showSpringboardScreen
Screen closed
Leaked bsc instances:
roAssociativeArray refcnt= 1 addr=0x5bf357b0
roString refcnt= 1 addr=0x5bf4c908 [auto-run-dev]
------ Running ------
Type args = roAssociativeArray
Type args.url = Invalid
showSpringboardScreen
Button pressed: 1 0
Displaying video:
srt = file://pkg:/source/craigventer.srt
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.
Current Function:
134: Function displayVideo(args As Dynamic)
135: print "Displaying video: "
136: p = CreateObject("roMessagePort")
137: video = CreateObject("roVideoScreen")
138: video.setMessagePort(p)
139:
140: bitrates = [0] ' 0 = no dots, adaptive bitrate
141: 'bitrates = [348] ' <500 Kbps = 1 dot
142: 'bitrates = [664] ' <800 Kbps = 2 dots
143: 'bitrates = [996] ' <1.1Mbps = 3 dots
144: bitrates = [1500] ' >=1.1Mbps = 4 dots
145: 'bitrates = [0]
146:
147: 'Swap the commented values below to play different video clips...
148:
149: ' Stream Info
150: urls = ["http://kitiosdevices-i.akamaihd.net/hls/live/202237/FFE_Roku/iOS/playlist.m3u8"]
151: qualities = ["SD"]
152: streamformat = "hls"
153: title = "The Music Channel"
154: srt = "file://pkg:/source/craigventer.srt"
155:
156: if type(args) = "roAssociativeArray"
157: if type(args.url) = "roString" and args.url <> "" then
158: urls[0] = args.url
159: end if
160: if type(args.StreamFormat) = "roString" and args.StreamFormat <> "" then
161: StreamFormat = args.StreamFormat
162: end if
163: if type(args.title) = "roString" and args.title <> "" then
164: title = args.title
165: else
166: title = ""
167: end if
168: if type(args.srt) = "roString" and args.srt <> "" then
169: srt = args.StreamFormat
170: else
171: srt = ""
172: end if
173: end if
174:
175: videoclip = CreateObject("roAssociativeArray")
176: videoclip.StreamBitrates = bitrates
177: videoclip.StreamUrls = urls
178: videoclip.StreamQualities = qualities
179: videoclip.StreamFormat = StreamFormat
180: videoclip.Title = title
181: print "srt = ";srt
182: if srt <> invalid and srt <> "" then
183: videoclip.SubtitleUrl = srt
184: end if
185:
186: video.SetContent(videoclip)
187: video.show()
188:
189: lastSavedPos = 0
190: statusInterval = 10 'position must change by more than this number of seconds before saving
191:
192: while true
193: msg = wait(0, video.GetMessagePort())
194: if type(msg) = "roVideoScreenEvent"
195: if msg.isScreenClosed() then 'ScreenClosed event
196: print "Closing video screen"
197: exit while
198: else if msg.isPlaybackPosition() then
199: nowpos = msg.GetIndex()
200: if nowpos > 10000
201:
202: end if
203: if nowpos > 0
204: if abs(nowpos - lastSavedPos) > statusInterval
205: lastSavedPos = nowpos
206: end if
207: end if
208: else if message.isrequestfailed()
209: return -5
210: else if message.isfullresult()
211: return -1
212: end if
213: end if
214: end while
215: End Function
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in ...QiB4p/pkg:/source/appMain.brs(208)
208: else if message.isrequestfailed()
Backtrace:
Function displayvideo(args As ) As
file/line: /tmp/plugin/ACAA...QiB4p/pkg:/source/appMain.brs(208)
Function showspringboardscreen(item As <uninitialized>) As Boolean
file/line: /tmp/plugin/ACAA...QiB4p/pkg:/source/appMain.brs(111)
Function main(args As ) As
file/line: /tmp/plugin/ACAA...QiB4p/pkg:/source/appMain.brs(36)
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:hls
title &h0100 String (VT_STR_CONST) val:Family Friendly Entertainment
srt &h0100 String (VT_STR_CONST) val:file://pkg:/source/craigventer.srt
videoclip &h0010 bsc:roAssociativeArray, refcnt=1
lastsavedpos &h0002 Integer val:0
statusinterval &h0002 Integer val:10
msg &h0010 bsc:roVideoScreenEvent, refcnt=1
nowpos &h0000 <uninitialized> val:Uninitialized
message &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger>
The video will play in side mode, but the application will not even load when I package and upload it to ROKU. Any idea on what I'm doing wrong?