Topic: Polling BTPlay Status

Hi everyone,

I wrote a simplistic MP3 player application for the Infocast 8 as a gift for my grandfather, who isn't very technologically inclined. The app lives on a tiny, permanently installed USB drive which gets run on startup via the debugchumby file. It keeps track of available MP3 files with an array, and plays them using BTPlay.

I have the whole thing working pretty well, except for one little issue... I know there are no BTPlay events accessible through Flash, so I'm polling _getPlayerStatus() to determine when a track ends in order to play the next one. About 30% of the time, it works like it should. The status switches from 2 ("playing") to 0 ("paused"/stopped) at the end of the track. Then my interval timer picks up the change and plays the next track in the sequence.

The other 70% of the time, it seems like the status never changes; it just stays on 2, then plays a random song out of sequence. Do you have any idea why this happens? I've debugged this for hours, so I'm confident that the problem is _getPlayerStatus() not changing. I made sure there aren't any playlists running in BTPlay, and I even dug into the source a little, but no luck... I'm wondering if there's a setting I'm overlooking.

I really appreciate your help! Thanks!


Re: Polling BTPlay Status

I wanted to briefly update this thread with my solution to the problem...

I double and triple checked my code, I scoured the forums and I dug deeper into the source code, but I couldn't determine what was causing BTPlay to play continuously. No matter what, the player status never changed when a track finished playing--it just continued on to a random new track--but the track attributes did change accordingly.

This is a pretty roundabout way of accomplishing what I wanted, but ultimately I started polling _getPlayerTrackAttributes() instead of _getPlayerStatus(). Whenever the returned attributes changed unexpectedly, the program assumed the last track ended. It's a little clumsy, but it worked well for my purposes.

I know the C8/Infocast is an excellent device, capable of so much more, but it's working great for my little niche application. It's such an esoteric thing, but maybe this little bit of insight will help someone else developing a native app in the future.

Take care,