That didn't really answer my question. I assume by "XML stuff" you mean the Scene Graph API. XML is nothing more that a structured way of representing data. XML is used by the Scene Graph API to represent the structure of a user-interface, but is also used in traditional Roku BrightScript programming to represent any structured data to be handled by a channel, e.g. an RSS feed. XML itself has nothing to do with creating timers.
If you choose to use the Scene Graph API then you have a lot of work ahead of you trying to figure out how to use it. If your only reason for using it is because you think it will allow you to display a countdown timer, then I'd recommend that you first attempt to develop your channel, including the countdown screen, using the standard components. If the channel doesn't look snazzy enough, then by all means redesign it to use the Scene Graph API.
Here's a simple example of a countdown screen using standard BrightScript components:
Sub Main ()
' GMT time when next event is to happen (e.g. 65 seconds from now)
dtNext = CreateObject ("roDateTime")
dtNext.FromSeconds (dtNext.AsSeconds () + 65)
' Display countdown screen
If displayCountdownScreen (dtNext)
' If countdown expired, display the video screen
displayVideoScreen ()
End If
End Sub
Function displayCountdownScreen (dtNext As Object) As Boolean
' Get the current GMT time
dtNow = CreateObject ("roDateTime")
' Don't display the countdown screen if time has already expired
secondsLeft = dtNext.AsSeconds () - dtNow.AsSeconds ()
If secondsLeft > 0
' Use an roImageCanvas to display a countdown timer
port = CreateObject ("roMessagePort")
ui = CreateObject ("roImageCanvas")
ui.SetMessagePort (port)
ui.SetLayer (0, {Color: "#303030"})
updateMessage (ui, secondsLeft)
prevUpdate = secondsLeft
ui.Show ()
' Loop until time expires or user presses a key
While True
' Check the timer every 500ms
msg = Wait (500, port)
' Invalid means that Wait timed out
If msg = Invalid
' Update the current time
dtNow.Mark ()
' Calculate how much time left
secondsLeft = dtNext.AsSeconds () - dtNow.AsSeconds ()
' Check if the countdown time has expired
If secondsLeft > 0
' Only update the screen if countdown timer has changed
If secondsLeft <> prevUpdate
updateMessage (ui, secondsLeft)
prevUpdate = secondsLeft
End If
Else
ui.Close ()
End If
Else If Type (msg) = "roImageCanvasEvent"
If msg.IsScreenClosed ()
Exit While
Else If msg.IsRemoteKeyPressed ()
ui.Close ()
End If
End If
End While
End If
' Return True if countdown timer has expired
Return secondsLeft <= 0
End Function
Function updateMessage (ui As Object, secondsLeft As Integer) As Void
LF = Chr (10)
uiMsg = "Your video will play in:" + LF + LF + secsToHMS (secondsLeft)
ui.SetLayer (1, {Text: uiMsg, TextAttrs: {Color: "#EBEBEB", Font: "Large"}})
End Function
Function secsToHMS (seconds As Integer) As String
h% = seconds / 3600
m% = (seconds - h% * 3600) / 60
s% = seconds Mod 60
Return h%.ToStr () + ":" + Right ("0" + m%.ToStr (), 2) + ":" + Right ("0" + s%.ToStr (), 2)
End Function
Function displayVideoScreen () As Void
Stop
End Function