Topic: playing music on chumby

Hi all, i just want to play some music which located in my own website on chumby.
I'm using Flash Pro 8, and in my fla file, i just added some simple codes:

var s:Sound = new Sound();

s.loadSound("http://doxuanhuyvn.freevnn.com/01%20jay%20chou%20-%20huang%20sha_2.mp3", false);

s.onLoad = function(success:Boolean):Void {

    if (!success) return;

    s.start();
};

It worked when i exported it in my laptop, but when i put it in my chumby, it did't work. The chumby keep reset every time i played the swf file (if i used profile.xml, it reset right after i touched at my application thumbnail, if i used ssh, it just stop ,just closing pid file with the last output:main() - closing and deleting pid file /var/run/chumbyflashplayer.pid)

Re: playing music on chumby

You want to use "true" for the second parameter for loadSound.

With "false" the sound is downloaded in its entirety before playing, which could exhaust the RAM.

By using "true" it should stream the sound.

Try that and let us know if it works.

3 (edited by ritsumeikan 2009-10-30 09:29:34)

Re: playing music on chumby

thanks for your reply.
I set the streaming flag to true.The only change is that it did not reset immediately, but still reset after about 10seconds.
My program do 2 things: first is loading image from my host, second is loading music from my host.
If i set the flag to false, chumby even did not load the image and reset immediately
If i set the flag to true, chumby did load the image, and after about 10seconds, it still reset.

I just saw some output that i think these ouput are about memory error:
2009-10-31 01:51:01 MemoryObject::!!! leaked chunk 0 block   0 ptr=0x70000000 4096K
2009-10-31 01:51:01 MemoryObject::!!! leaked chunk 1 block   0 ptr=0x70400000 1600K
2009-10-31 01:51:01 MemoryObject::!!! leaked chunk 1 block  61 ptr=0x705e8000 2144K
2009-10-31 01:51:01 MemoryObject::!!! leaked chunk 2 block   0 ptr=0x70800000 1952K

I just have a little thought that may be my mp3 file quality and my host is too bad, or not compatible with chumby?

Re: playing music on chumby

MP3 streaming is a *very* recent addition to Flash Lite - however, we've had some success using it to stream audio in a widget. A couple of other developers (cbreeze in particular) have done the same.

However, it's very sensitive to the format of the MP3 and other factors.

Do a search on the forum for "loadSound" and you might find some helpful information.

Re: playing music on chumby

I've done some another tests with another music file (with several other bitrates: 128, 256kbs), it worked some times! But almost the time it did not work well, stop immediately or after about 1minute.
I've tested  jukebox application from wrybread which stream radioplaylist pls file, it worked perfectly, can you tell me differences between streaming pls file and streaming mp3 file?

By the way, if you have free time , can you take a look at my 2 mp3 file which located at
http://doxuanhuyvn.freevnn.com/Ave%20Maria-Schubert.mp3
http://doxuanhuyvn.freevnn.com/01%20jay … 0sha_2.mp3
and see what's happening? Thanks you a lot.

Re: playing music on chumby

"pls" files are simply playlists - they're text files that contain a list of URLs to the actual streams themselves.

Re: playing music on chumby

I tried your streams in the "My Streams" music source on the chumby, which uses a separate music player (not Flash) to play the music.

As with your experience with Flash, the music cut off after about a minute.  Worse yet, the socket was being held open by the server even though no audio was coming down the pipe, which might explain some of your crashes.

I then pulled the files down onto the device itself and played them locally using the same player and they worked fine.

That means that two different MP3 player applications cut off after about a minute while streaming, but not when playing locally.

This points to a configuration issue on the server, which seems to cut off downloads after a minute, thus not suitable for the progressive HTTP download required for realtime streaming.  That's pretty typical for servers that are designed to be repositories of audio files, but not "broadcasters" of those files.  Some buffering streaming players might be able to handle them, but the chumby (and many other similar devices) don't have the memory to buffer.

This was just a quick look - not a definitive proof of a problem here.  If someone would like to reproduce my experiment that might be helpful.

8 (edited by cbreeze 2009-10-31 10:39:17)

Re: playing music on chumby

This file smoked my chumby! big_smile

It looks like it was something funny with the encoding (which seems to be the problem most often in these situations).

I "re-encoded" the file via iTunes (quick, easy, and clean).  Renamed it to get rid of the "%20's" and ran it with the following code on the main timeline:

stop();

var s:Sound = new Sound(_root);
s.loadSound("http://www.pathtoserver.com/your.mp3", true);

From what I have read, you are not required to call s.start() when flagging a sound for streaming.  Not sure if it causes an issue by having it included.

Also, though I am sure it's obvious, make sure you set the widget play time to something greater than the song length.

Cheers.

Re: playing music on chumby

thanks you guys.
May be i have to re-encode my mp3 files, and find another better host.

Re: playing music on chumby

First try the reencoding - that might be enough to fix it.  It's possible that your server is OK but that the encoding bothered the streamer more than playing locally.

Re: playing music on chumby

How'd you guys download 'em?  I'm being forwarded to some other domain.  I was going to analyze the files (CODEC development is what I've done for a living for the last fifteen [cough] almost twenty years. . .)

---
I Void Warranties (tm)

Re: playing music on chumby

I used curl on a Mac, though curl on a chumby will work too:

# curl "http://doxuanhuyvn.freevnn.com/Ave%20Maria-Schubert.mp3" > avemaria.mp3

The directory containing the files is visible here, so I'd expect any browser to be able to download them.

From my location, the server appears to be accessed through a web proxy cache called "lusca" (apparently based on squid 2) - not sure if that's interfering somehow.

Re: playing music on chumby

That was really odd.  I tried just grabbing it with a browser - and I was getting nowhere.  A wget worked fine though.  (probably should have thought "curl" first.)

Thanks, Duane!

---
I Void Warranties (tm)

Re: playing music on chumby

I have had to overcome quite a few challenges while trying to get my streaming MP3 sound working properly on my flash/widget.

Below are some of the lessons learned in the process, that someone may find useful:

- The MP3 encoding format (bit rates & frequency) is quite touch and go with the chumbyflashplayer and getting those wrong may get your sound to play like Donald Duck on caffeine. Experiment with the most standard combinations first. Another place you might be able to tweak this is through the chumbyflashplayer command line parameter '-p' (type 'chumbyflashplayer.x --help' on the SSH prompt to find out more)

- Make sure to set the streaming parameter as 'true' in the loadsound() function. Setting this 'false' should technically allow the sound to play in non-streaming mode, but in my experience the sound has been extremely jumpy and broken even on a wired LAN connection. I would highly not recommend using this mode.

- The most annoying problem I have had so far was a sound overlap issue, particularly prominent when running the flash movie directly (not as a widget). This occurs when you stop a sound mid-way and then load another sound into the same or a different sound object. When the new sound is accessed, it would play about 3 seconds of the old sound from some buffer and would loose the first 3 seconds or so from the beginning of the new sound. To resolve this, use the '-n' command line parameter to configure the sound buffer, when starting the movie with the chumbyflashplayer.x command. The default value for '-n' is 16, with recommended values being between 4 and 32, but in my experience setting the value to 2 has almost eliminated the overlap.

UNRESOLVED PROBLEM (please help if any one has faced a similar issue):
All sound functions on the Flash application consistently stop working after about 6-7 hours of leaving the application/widget running continuously on the Chumby, thus making it quite un-reliable for real world use. The application itself is still fully responsive. Sounds can still be played fine by using btplay through an SSH session. The only way to fix the sound in the application/widget is to reload/restart the app. The exact same flash application works fine for days together on a PC or through a web-browser without a problem? The application makes use of the loadsound() function to stream and play the MP3. The MP3 file itself is still accessible through the SSH session.

I have really hit a blank wall with the above issue and any help would be greatly appreciated!!

Re: playing music on chumby

Is your app running locally or as a "private" widget?

I think you bring up some good tips, but there is an overlap between what you are discussing.  There are 2 modes of play.  Using btplay via a local (usb) widget and audio via the actual Flash decoder.  Are your questions in relation to both modes of play, or a specific one?

Cheers.

Re: playing music on chumby

Thanks for your response cbreeze.

Yes, I do intend to run my app as a private stand-along app (non-widget mode), although my tests even through the widget mode have yielded me the same results (sound still stops functioning afer 6-7 hours).

cbreeze wrote:

There are 2 modes of play.  Using btplay via a local (usb) widget and audio via the actual Flash decoder.  Are your questions in relation to both modes of play, or a specific one?

So far I have only been utilizing the Flash decoder (loadsound() function) to play the sound file through my app. The only time I used btplay was from the ssh session to test whether the actual speaker-hardware was still functional when the flash app-sound stopped working, which resulted in a positive.

Based on your idea, I am now thinking of modifying my program to use btplay to run the sound instead of the flash decoder, but am not aware of the power or limitations of btplay access through flash. At the very least I would need:
- options to start/stop the sound from within flash
- an option to play an MP3 from the web in streaming mode
- possibly indicate the sound-progress back to the flash app (good to have but not critical for my purpose)
- an onSoundComplete sort of flag to prompt the flash app when done (critical)

The only reference I have found so far for implementing btplay is here. I'm researching it right now with my fingers crossed.. smile. My major concern is that there doesn't seem to be a ready trigger to indicate that the sound has finished playing, so I guess I'll need to query the 'player state' every second or so to find out, which does seem a bit tacky. Lets see if it works without crashing after my critical 6th hour!

If you have implemented btplay through a flash app before, any tips you may wish to share would be more than welcome.

Thanks once again.

17 (edited by ritsumeikan 2009-12-03 08:23:32)

Re: playing music on chumby

techgermz wrote:

Thanks for your response cbreeze.

Yes, I do intend to run my app as a private stand-along app (non-widget mode), although my tests even through the widget mode have yielded me the same results (sound still stops functioning afer 6-7 hours).

cbreeze wrote:

There are 2 modes of play.  Using btplay via a local (usb) widget and audio via the actual Flash decoder.  Are your questions in relation to both modes of play, or a specific one?

So far I have only been utilizing the Flash decoder (loadsound() function) to play the sound file through my app. The only time I used btplay was from the ssh session to test whether the actual speaker-hardware was still functional when the flash app-sound stopped working, which resulted in a positive.

Based on your idea, I am now thinking of modifying my program to use btplay to run the sound instead of the flash decoder, but am not aware of the power or limitations of btplay access through flash. At the very least I would need:
- options to start/stop the sound from within flash
- an option to play an MP3 from the web in streaming mode
- possibly indicate the sound-progress back to the flash app (good to have but not critical for my purpose)
- an onSoundComplete sort of flag to prompt the flash app when done (critical)

The only reference I have found so far for implementing btplay is here. I'm researching it right now with my fingers crossed.. smile. My major concern is that there doesn't seem to be a ready trigger to indicate that the sound has finished playing, so I guess I'll need to query the 'player state' every second or so to find out, which does seem a bit tacky. Lets see if it works without crashing after my critical 6th hour!

If you have implemented btplay through a flash app before, any tips you may wish to share would be more than welcome.

Thanks once again.

Thanks you for your tricks above.
By the way, how do you implement btlay method in the flash MX with FLA file (is ASnative function implemented in flash mx?)
I found that mp3 streaming is very stable with btplay, but i don't know how to implement this with flash MX

Re: playing music on chumby

> All sound functions on the Flash application consistently stop working after about 6-7 hours of leaving the application/widget running continuously on the Chumby, thus making it quite un-reliable for real world use.

Yes, I have had this problem as well.  I've had some success with delete'ing the Sound object every hour or two (after explicitly delete'ing any assigned function properties first) and then recreating it.

Another, possibly related, problem is that sometimes my app will get an .onLoad(true) event but no .onSoundComplete() event.  This is probably happening due to transient network errors as the sound streams - but then my app is hung waiting for the .onSoundComplete() event.  One workaround, which I've not yet tried, is to set a timer for 2X the expected playback time of the sound file after getting the .onLoad(true) event.  If the .onSoundComplete() event is not received before the timer expires, the app could delete and recreate the sound object - and hopefully continue normally.  Or does anyone know if there is another event from the Sound object that can be monitored to detect this condition?