function loopvideo() as integer
continue=1
while continue=1
continue=displayvideo()
end while
end function
function displayvideo(args As Dynamic) as integer
while true
msg = wait(0, video.GetMessagePort())
if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed() then 'ScreenClosed event
print "user cancelled playback, closing video screen"
return 0
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
if nowpos > 0
if abs(nowpos - lastSavedPos) > statusInterval
lastSavedPos = nowpos
end if
end if
else if msg.isRequestFailed()
return 1
else
return 1
end if
end if
end while
return 1
function loopvideo() as integer
continue=1
while continue=1
continue=displayvideo()
if continue=1 then
sleep(5000) 'five second delay
end if
end while
end function
' ********************************************************************
' ** Simplevideoplayer - adapted by Cory 6-29-2012
' ********************************************************************
Sub Main(args As Dynamic)
displayVideo(" ")
End Sub
'*************************************************************
'** displayVideo()
'*************************************************************
Function displayVideo(args As Dynamic) as integer
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]
' Live stream from Wowza server
urls = ["http://myserver:1935/live/livestream.sdp/playlist.m3u8"]
qualities = ["SD"]
streamformat = "hls"
title = "Livestream"
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 "user cancelled playback, closing video screen"
return 0
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
if nowpos > 0
if abs(nowpos - lastSavedPos) > statusInterval
lastSavedPos = nowpos
end if
end if
else if msg.isRequestFailed()
return 1
else
return 1
end if
end if
end while
return 1
End Function