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: 
rsromeo
Channel Surfer

WAITING FOR AN EVENT

Hi -

Was wondering if someone could clue me in on how to do something. I have an audio player object loading an mp3 file. While the player is loading the file, it gives the "startup progress" message and I display one line dialog saying "buffering, etc."

But if the link is bad, it never quits the loop. It doesn't give any other messages, just sticks on "startup progress" so how can I tell it to time out after XXXX seconds and display a message dialog "cannot connect, etc." ?
0 Kudos
2 REPLIES 2
RokuChris
Roku Employee
Roku Employee

Re: WAITING FOR AN EVENT

This is a common problem. One way to detect a stalled buffer is if you don't receive any events from your audio player for some period of time before receiving the "start of play" message. Here's a simple event loop that does that. This is from memory, so it may not work exactly as is, but the concept is there.

audioPlayer.Play()
isBuffering = true

while true
msg = wait(5000, audioPlayer.GetMessagePort())
if msg <> invalid
' we have a valid message
if msg.isStatusMessage()
if msg.GetMessage() = "start of play"
' buffering was successful
isBuffering = false
end if
end if
else
' no message received in 5 seconds
if isbuffering
' handle a stalled buffering situation
end if
end if
end while
0 Kudos
rsromeo
Channel Surfer

Re: WAITING FOR AN EVENT

Thanks RokuChris. I'll give it a try.
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.