Topic: Streaming MP3

I know you can't stream MP3 in Flash 1.1, but can you in 2.0, or did you add that feature?

I was working on something, and I think that might be the cause of the problem sad

Re: Streaming MP3

No, streaming of MP3 is not supported in FlashLite 2.

It will download and and attempt to play MP3 files once they're completely downloaded - however, the current chumby player does not support it.  We're working on a version that will.

For the time being, you'll have to embed MP3s in SWFs - you can do a server-side script to do it using something like Ming.

Re: Streaming MP3

Okay, thanks.
I don't know if I could set up a server-side script, its not my MP3's (I was trying to use Hype Machine)
I've never heard of Ming, I'll check it out and see what I can do.

Re: Streaming MP3

I've worked on a prototype which uses Ming to put mp3s in a swf wrapper. It already can stream my entire mp3 collection with the help of a local server but the reason why I haven't published it is that the chumby always chokes on certain mp3s which is probably caused by the datarate or the package size produced by Ming. I've already tried an alternative solution using ffmpeg, but the result is the same. What is interesting though is that the Chumby never seems to choke on mp3s embedded in swfs that have been exported with the Flash IDE. Looking at the swf structure of those files with a Flash decompiler reveals that the packages are indeed slightly different. The problem is that I don't know how to tell ming or ffmpeg to use different package sizes.

My next task is to use some kind of preprocessor which reduces the datarate of the mp3s before packaging then in Ming.


Here is some basic PHP code to wrap mp3s into swfs using Ming - it assumes that you have done some preprocessing and know the length of your mp3 in seconds. You also will need PHP with the Ming extension compiled in.

<?php
       // $mp3path is the path to your mp3 file
       // $secs is the length of the mp3 in seconds
     
    $m = new SWFMovie();
    $m->setRate(12.0);
    $m->streamMp3(fopen($mp3path, "rb"));
    $m->setFrames(ceil(12*$secs));

    header('Content-type: application/x-shockwave-flash');
    $m->output();

?>

Re: Streaming MP3

I'm going to have to back away from this, I wasn't able to install Ming (the CVS was unusable).
Good to know, though...

Re: Streaming MP3

Quasimondo wrote:

... the reason why I haven't published it is that the chumby always chokes on certain mp3s which is probably caused by the datarate or the package size produced by Ming

This is apparently the case with any FlashLite 2 implementation, not just chumby.  We've seen this before, and when we tried the same SWFs on other FL2 devices, we got the same result. It seems the FlashLite MP3 decoder has some sensitivities.  Hopefully this will be addressed by Adobe at some point.

Re: Streaming MP3

I have no experience with FlashLite but I have run into MP3 streaming issues with Flash. Given the similar codebase I can only assume that some of the quirks may be shared:

- it doesn't like variable bitrate MP3s
- sample rate must be a multiple of 11Khz

More possibly relevant info here: http://www.jeroenwijering.com/?thread=3358

Hope that helps...

Re: Streaming MP3

Hacked a quicky chumlet and got our live webcast radio streaming mp3 on the virtual chumly. Dont have the real thing yet, but if the virtual chum is running the same flashlite version, then streaming mp3 is possible. Check out "Entertainment" "Harvest Valley Radio" . Also, I wouldnt mind developing further and providing a complete interactive flash (like our existing website www.khvr.com) for the chumly.

Re: Streaming MP3

Update:  The current production chumbys, which are shipping to the first customers this month, are able to load and play back external mp3 files progressively.  So you no longer have to wrap the mp3 in a swf.  If it works in the virtual chumby (currently published for Flash 7) then it's likely to work in the production chumby.

Keep in mind that to load an external mp3 you'll need a crossdomain.xml file on the server that hosts the mp3.  The crossdomain file should allow access from *.chumby.com, since that's where the swf's are coming from.

Re: Streaming MP3

So we understand that in this the Chumby operates in somewhat different way that FL 2.x specs. It allows for streaming MP3s, i.e. the isStreaming parameter of loadSound() is active.
Now I doubt what you say about crossdomain is correct. Crossdomain permissions are needed if you were to access any data in the MP3 (like ID3 values). NOT needed to just play the MP3. At least that's the behaviour in FL8 and 9

Re: Streaming MP3

The production chumbys are running Flash Lite 3.

We'll check the issue of crossdomain.xml -  the documentation for FL3  isn't very clear on this particular topic.

Re: Streaming MP3

Ok, so how do I get this working?

Anybody have all the pieces together?

Re: Streaming MP3

I don't know about the FL's, but for the older ones, instead of calling up the .mp3, you'd call up a PHP file with the .mp3 link as a parameter, and embed the resulting swf.

Re: Streaming MP3

It seems the best approach is to use a shoutcast server  and the btplay executable on the chumby.

from sshd you can execute btplay http://85.214.115.44:80

So the trick is how to enable and select different servers from the chumby without using the sshd and terminal.

Re: Streaming MP3

So far, the solution is to throw links to actions like this on the web server and control them from the web, but that's not a very ideal solution, even if it works pretty well, especially since you have to enter URLs and such).

Re: Streaming MP3

In flash, can't you execute programs by opening up an XML request to
"exec:/path/to/whatever"
So maybe "exec:/mnt/usb/btplay_this"
where btplay_this is an executable:
#!/bin/sh
btplay http://85.214.115.44:80

(I dont know how well the exec: handles the spaces and such, you could probably use the HTTP escape stuff, like %20)

Re: Streaming MP3

Duane wrote:

No, streaming of MP3 is not supported in FlashLite 2.

It will download and and attempt to play MP3 files once they're completely downloaded - however, the current chumby player does not support it.  We're working on a version that will.

For the time being, you'll have to embed MP3s in SWFs - you can do a server-side script to do it using something like Ming.

Hi Duane,

Any update on this functionality? I'm pretty surprised that FlashLite 3.0.2 isn't rocking the beats!

I just learned the hard way after using Sound.loadSound('...mp3') in a new widget that the results are ugly. It loads the mp3 and plays it, but the sound that comes out is crazy! - similar to what some people described when recording and playing from the microphone using ssh - loud digital static with a faint hint of the actual audio in the background.

Attaching the sound to my swf works fine, and audio from flv works too. I really want the audio to be external from my widget and don't like the idea of swf audio files very much. I'd sooner use flv and video objects for my sound than package swfs. Maybe I'm just more into video encoding than publishing swf files... but that's just me.

Anyway it seems like the lack of streaming/progressive mp3 playback in flash on chumby is a huge limitation. That just throws podcast widgets out the window. We have blog widgets galor and text isn't that great on chumby. Images are nice, but with video performance is lacking. It's all about the beats man!

Re: Streaming MP3

Nothing has changed with FL3.0.2 - the player still loads the sound completely before playing it.

However, I'm quite interested in why you're getting static.  If you could please email me (duane@chumby.com) a link to your MP3 file, I'd like to take a look at it and see what's happening.  Oftern we discover that these files aren't actually MP3 (aka MPEG-1 Layer III), but rather MPEG-2 Layer III, or some sample rate that Flash Lite does not support.

As to the microphone "issue" - if you read the whole thread, you can see that it was being used incorrectly, and when used properly it works just fine.