I'm currently writing a function meant to check if a livestream is playing. My hope is that I will be able to use it to indicate to a viewer scrolling through a menu that a stream is taking place. My current attempt at the task has resulted in a function that essentially crashes the program, although the console debugger has no say as to why this is the case. Can anybody please help me figure out what my issue here is?
function IsLive() as Boolean
test = CreateObject("roVideoScreen")
port = CreateObject("roMessagePort")
test.setMessagePort(port)
vid = CreateObject("roAssociativeArray")
vid.HDBranded = false
vid.IsHD = true
vid.StreamFormat = "mp4"
vid.Stream = { url: "[livestream url]"
bitrate: 2000,
quality: true,
contentid: "CalvaryCCM"
}
test.setContent(vid) 'note that the video isn't actually shown. This object is created simply to check if a livestream exists.
while true
msg = wait(0, port)
if type(msg) = "roVideoScreenEvent" then
if msg.isStatusMessage()
print "status message: "; msg.GetMessage()
else if msg.isPlaybackPosition()
print "playback position: "; msg.GetIndex()
return true
else if msg.isRequestFailed()
print "request failed - error: "; msg.GetIndex();" - "; msg.GetMessage()
return false
end if
end if
end while
return false 'assuming this while loop is completely circumvented, function ends with assumption that the stream isn't live
end function
I AM THE ARCHMAGE... who is also rather new to Brightscript so forgive me for seeming inept at times.