Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
scrager
Visitor

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.
0 Kudos
5 REPLIES 5
scrager
Visitor

Re: audio roSpringBoardScreen progress indicator

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.
0 Kudos
greubel
Visitor

Re: audio roSpringBoardScreen progress indicator

Here is a snippet that works for me !
--------------------------------------------
msg = wait(1000, port)
if msg = invalid
if play = 1 and pause = 0
if ready = 0 and lapse >= 5000
play = 0
ap.Stop()
Disp( o.Lookup("Title"), " Failed to Play" )
exit while
end if
lapse = lapse + 1000
sb.SetProgressIndicator( lapse, total )
sb.Show()
end if
goto mylabel
end if
--------------------------------------------
Total = time in milliseconds
0 Kudos
evilmax17
Visitor

Re: audio roSpringBoardScreen progress indicator

Bump.

Are there best practices for keeping track of audio progress? None of the examples in the SDK use SetProgressIndicator.
My Roku Channels:
Viddler - viddler.com
Tested Fan - tested.com | Jamie & Adam
This is my next - theverge.com
1080p Showcase - RIP
Whiskey Media - RIP
======================
http://www.binarymoustache.com
0 Kudos
RokuKevin
Visitor

Re: audio roSpringBoardScreen progress indicator

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
0 Kudos
TheEndless
Channel Surfer

Re: audio roSpringBoardScreen progress indicator

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
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.