Try this version, its a hack but it presents a better timer indicating that something is happening
Sub Main()
hideL = -1
backL = 0
helloL = 1
videoL = 2
promptL = 3
messageL = 4
playerRect = { x: 50, y: 120, w: 630, h:452 }
punchRect = playerRect
back = { Color:"#FFFFFFFF", CompositionMode:"Source"}
hello ={
Text:"Press Ok To Start Movie, Back To Exit"
TextAttrs:{Color:"#FFCCCCCC", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:100 + 630 + 10,y: 120 + 30,w:500,h:60}
}
prompt ={
Text: "TIME TO LOAD: " + " 0 " + "SECONDS "
TextAttrs:{Color:"#FFCCCCCC", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:100 + 630 + 10,y: 120 + 30 + 60,w:500,h:60}
}
message ={
Text: "Video Player Is Stopped"
TextAttrs:{Color:"#FFCCCCCC", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:0,y: 120 + 452 + 20,w:1280,h:60}
}
video = {
Color: "#00000000"
TargetRect: punchRect
CompositionMode: "Source" }
content = {
Stream: {
url: "http://guitar.objects.cdn.dream.io/VIDEOS/CCRyderB.m4v"
bitrate: 128
quality: True
contentId: "video"
}
StreamFormat: "mp4"
SwitchingStrategy: "full-adaptation"
}
timer = CreateObject( "roTimeSpan" )
canvas = CreateObject( "roImageCanvas" )
port = CreateObject( "roMessagePort" )
canvas.SetMessagePort(port)
VPlayer = CreateObject( "roVideoPlayer" )
VPlayer.SetMessagePort( port )
VPlayer.SetDestinationRect( playerRect )
VPlayer.AddContent( content )
canvas.SetLayer( backL , back )
canvas.SetLayer( videoL, video )
canvas.SetLayer( helloL, hello )
canvas.SetLayer( promptL, prompt )
canvas.SetLayer( messageL, message )
canvas.Show()
loading = False
seconds = timer.TotalSeconds()
while(true)
msg = port.GetMessage()
if loading
newSecond = timer.TotalSeconds()
if newSecond > seconds
seconds = newSecond
prompt.Text = "LOADING: " + seconds.ToStr() + " SECONDS"
canvas.SetLayer( promptL, prompt )
canvas.Show()
end if
end if
if type(msg) = "roImageCanvasEvent" then
if (msg.isRemoteKeyPressed()) then
i = msg.GetIndex()
if (i = 0) then
VPlayer.Stop()
canvas.close()
else if i = 6
VPlayer.Stop()
prompt.Text = "TIME TO LOAD: " + " 0 " + "SECONDS "
canvas.SetLayer( promptL, prompt )
canvas.Show()
sleep( 200 )
timer.Mark()
VPlayer.Play()
loading = True
seconds = timer.TotalSeconds()
end if
else if (msg.isScreenClosed()) then
print "Closed"
return
end if
else if type(msg) = "roVideoPlayerEvent" then
gmsg = msg.GetMessage()
print gmsg
message.Text = msg.GetIndex().ToStr() + " " + gmsg
canvas.SetLayer( messageL, message )
canvas.Show()
if gmsg = "startup progress"
loading = True
else if gmsg = "start of play"
prompt.Text = "TIME TO LOAD: " + timer.TotalSeconds().ToStr() + " SECONDS"
canvas.SetLayer( promptL, prompt )
canvas.Show()
loading = False
else
loading = False
end if
end if
end while
End Sub
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )