rsromeo
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2010
08:05 AM
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." ?
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." ?
2 REPLIES 2


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2010
08:20 AM
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
rsromeo
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2010
03:20 PM
Re: WAITING FOR AN EVENT
Thanks RokuChris. I'll give it a try.