Here's an example showing both the date/time when the stream will play, as well as a countdown timer. All the elements you need should be there. It'll be worth your while to try and understand the code, looking up stuff you don't understand in the BrightScript Reference, or the Component Reference for roDateTime and roListScreen, then modify your own code accordingly. If you still don't understand anything, then feel free to ask.
Sub Main ()
' Get the content list from somewhere
contentList = getContentList ()
' Get the next event time somehow (e.g. 65 secs from now)
dtNext = CreateObject ("roDateTime")
dtNext.FromSeconds (dtNext.AsSeconds () + 65)
' Display countdown screen
displayMainScreen (contentList, dtNext)
End Sub
Function displayMainScreen (contentList As Object, dtNext As Object) As Void
' Get the current GMT time
dtNow = CreateObject ("roDateTime")
' Display content list using an roListScreen
port = CreateObject ("roMessagePort")
ui = CreateObject ("roListScreen")
ui.SetMessagePort (port)
ui.SetContent (contentList)
ui.Show ()
' Keep track of which item is focused
focusedIndex = 0
While True
' Check for countdown completion every 500 milliseconds
msg = Wait (500, port)
' Invalid is returned from Wait if a timeout occurs
If msg = Invalid
' Update the current time
dtNow.Mark ()
' Check how much time is left -- assumes all content items have same countdown time
secondsLeft = dtNext.AsSeconds () - dtNow.AsSeconds ()
' Check if the countdown time has expired
If secondsLeft > 0
' Countdown still running - modify content item with the time remaining
contentItem = {}
' Keep the title the same
contentItem.Title = contentList [focusedIndex].Title
' Modify ShortDescriptionLine 1/2 with the stream time and countdown timer
contentItem.ShortDescriptionLine1 = "streaming at: " + formatDateTime (dtNext)
contentItem.ShortDescriptionLine2 = "time left: " + formatTimeLeft (secondsLeft)
' Replace the focused content item with the modified item
ui.SetItem (focusedIndex, contentItem)
Else
' Coundown has expired - display original content item
ui.SetItem (focusedIndex, contentList [focusedIndex])
End If
Else If Type (msg) = "roListScreenEvent"
If msg.IsScreenClosed ()
Exit While
Else If msg.IsListItemFocused ()
' Keep track of which list item is focused
focusedIndex = msg.GetIndex ()
Else If msg.IsListItemSelected ()
' Play the selected video item
displayVideoScreen (contentList [focusedIndex])
End If
End If
End While
End Function
' Format a date time object: mm/dd/yy hh:mm:ss
Function formatDateTime (dtGMT As Object) As String
' Convert GMT roDateTime to local
' Note - make a copy of dtGMT, to avoid multiple calls to ToLocalTime on same object
dtLocal = CreateObject ("roDateTime")
dtLocal.FromSeconds (dtGMT.AsSeconds ())
dtLocal.ToLocalTime()
h$ = Right ("0" + dtLocal.GetHours ().ToStr (), 2)
m$ = Right ("0" + dtLocal.GetMinutes ().ToStr (), 2)
s$ = Right ("0" + dtLocal.GetSeconds ().ToStr (), 2)
Return dtLocal.AsDateString ("short-date") + " " + h$ + ":" + m$ + ":" + s$
End Function
' Format the time left: "h:mm:ss"
Function formatTimeLeft (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
' Add code here to play the selected video content item
Function displayVideoScreen (contentItem As Object) As Void
Stop
End Function
' Returns array of content meta-data items (hard-coded here, but could use XML, JSON, etc)
Function getContentList () As Object
contentList = []
contentList.Push({Title: "Title-1", ShortDescriptionLine1: "Desc-1a", ShortDescriptionLine2: "Desc-1b"})
contentList.Push({Title: "Title-2", ShortDescriptionLine1: "Desc-2a", ShortDescriptionLine2: "Desc-2b"})
contentList.Push({Title: "Title-3", ShortDescriptionLine1: "Desc-3a", ShortDescriptionLine2: "Desc-3b"})
contentList.Push({Title: "Title-4", ShortDescriptionLine1: "Desc-4a", ShortDescriptionLine2: "Desc-4b"})
Return contentList
End Function
EDIT: Display time using user's local time zone.