"belltown" wrote:
Good point. I've edited my example code above to display the time using the user's local time zone. As Mark said, make sure the time calculations are done using GMT time. If your server returns time in a different time zone, then convert from that time zone to GMT before doing any further calculations on the time.
Hi there! This is me, replying a few days later. I took a good hard look at your code and I was able to get a description of streaming time in the description categories of the roListScreen nodes, so that was exciting! I am still struggling with the countdown timer I'm trying to make, however. I did realize what my problem was: I was misunderstanding the use of the Timer node in roSGNode. I am instead trying to make a Label node to display time in an hh:mm:ss format. My strategy is to update the label every second and change the time. If there is a more efficient way of making a visual countdown timer, please let me know.
In the meanwhile, I'm having trouble understanding how to add fields to the roSGNode when I create them, and how to make them the focused object on the screen. The following is my code with my best guess as to how it's done. I would appreciate it if somebody could help me figure out what I'm doing wrong (when I attempt to create a node, I get an error in the console saying "Failed to create roSGNode with type Label):
'live is an associative array with the following values:
' start = time which the stream should start
' end = predicted end time for the livestream
' current = a roDateTime object to represent the system time (in UTC)
'stream is just an associative array with one member: stream
' stream contains the fields needed to create the livestream,
' when used as a field in VideoPlayer()
sub CountdownDisplay(live as object, stream as object)
'create initial objects and show scene, so node can be created later
screen = CreateObject("roSGScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()
'obtain the time left for initial display of countdown timer
secondsLeft = live.start.AsSeconds() - live.current.AsSeconds()
'here I need to do something to create a visual countdown display
countdown = CreateObject("roSGNode", "Label") 'because this fails to execute, the next three lines crash the program
countdown.vertAlign = center
countdown.horizAligin = center
countdown.text = CountdownTime(secondsLeft) 'CountdownTime() returns a string with format hh:mm:ss
while true
msg = wait(1000, port) 'check for updates every second
if msg = Invalid
live.current.Mark() 'mark the time to ensure it's up to date
secondsLeft = live.start.AsSeconds() - live.current.AsSeconds() 'update secondsLeft
if secondsLeft > 0
'here I need to modify the countdown to display an updated time
countdown.text = CountdownTime(secondsLeft)
else
'assume wait time is over, get rid of the countdown screen, and go to the livestream
screen.Close()
VideoPlayer(stream)
end if
else if type(msg) = "roSGScreenEvent"
if msg.IsScreenClosed()
exit while
end if
end if
end while
return
end sub
I AM THE ARCHMAGE... who is also rather new to Brightscript so forgive me for seeming inept at times.