audio roSpringBoardScreen progress indicator

Is it possible to sync the progress indicator on a spring board screen to a playing audio player automatically?

If not, I assume that in the while loop that waits for events, the wait command needs to wait for a period of time, not 0. On each loop, calculate the time played and adjust the progress indicator accordingly.

So i tried that, but I am not sure of a good way to calculate time. I tried this:


playstart = uptime(0)
maxplay = 190

while true
   msg = wait(1000,port)

   ....

   playtime = uptime(0) - playstart
  screen.setprogressindicator(int(playtime),maxplay)

end while

but uptime does not seem to count in seconds even though the documentation says it does. it seems to count 1/10 second for every real second, but it is not consistent.

So is my calculation wrong? Is there a better way to calculate time or am I going about this wrong? I did not see any progress indicators in any of the sample code.

I found the roDateTime object that seems to work a lot better than uptime

I’d still like to know if it is possible to sync a springboard screen to a player to have the progress indicator updated automatically.

Bump.

Are there best practices for keeping track of audio progress? None of the examples in the SDK use SetProgressIndicator.

Greubel’s example is the best way to do it currently. The Roku does not send audio progress events, so you must keep track of the time in your app.

–Kevin

gruebel’s example looks like it will get out of sync if the wait loop receives any valid messages. As scrager suggested, I’d recommend using an roDateTime object for better accuracy.

I do something like this…

content = { mycontent }

playbackTimer = CreateObject( "roDateTime" )
isPlaying = False
isPaused = False
isBuffering = False

content.CurrentPosition = 0
audioPlayer.SetContentList( [ content ] )
audioPlayer.Play()
While True
	msg = Wait( 1000, audioPlayer.GetMessagePort() )
	If msg <> invalid Then
		If msg.IsRequestFailed() Or msg.IsPartialResult() Or msg.IsFullResult()Then
			isBuffering = False
			isPlaying = False
			Exit While
		Else If msg.IsPaused() Then
			' We paused, so record the current playback timer position
			content.CurrentPosition = content.CurrentPosition + playbackTimer.TotalSeconds()
			isPlaying = False
			isPaused = True
		Else If msg.IsResumed() Then
			' We resumed, so restart the playback timer
			m.PlaybackTimer.Mark()
			isPlaying = True
			isPaused = False
		Else If msg.IsStatusMessage() Then
			If msg.GetMessage() = "startup progress" Then
				isBuffering = True
				' Show buffering message here
				' Should also reset playback timer if isPlaying = True
			Else If msg.GetMessage() = "start of play" Then
				' Start the playback timer
				playbackTimer.Mark()
				isPlaying = True
				isBuffering = False
			End If	
		End If
	End If
End While