views:

144

answers:

2

Hi!

I have a list of mp3 files which I automatically build together to different, larger, mp3 files with the *nix command 'cat'. They work fine to play in any installed mp3 player I've tested them in, but I have also written a small, easy-to-use mp3 player in ActionScript 3 where I wanted to play my (concatinated) mp3 files over the web.

However, Flash Players doesn't seem to be able to read the whole concatinated file - only the first part of them (the first, smaller, mp3 file contained in the larger file). How can I work this out? I would love to be able to solve this with ActionScript instead of creating the concatinated files in any other way.

My ActionScript looks similar to this;

...
    private function loadTrackAndPlay():void {
        track = new Sound();
        track.addEventListener(Event.COMPLETE, playTrack);
        var req:URLRequest = new URLRequest('concatinated.mp3');
        track.load(req);
    }

    private function playTrack(e:Event):void {
        track.removeEventListener(Event.COMPLETE, playTrack);
        track.play();
    }
...
+1  A: 

I don't believe the result of what you are doing is an actual valid mp3 file. Also, Flash is very picky about the mp3s it can play. Your best bet is to load the files individually and just listen for the SOUND_COMPLETE event coming off of your SoundChannel object (you get an instance of SoundChannel when you run your sound's play method).

Branden Hall
This was the way to go (unfortunately), thanks for input.
Björn
+1  A: 

It should be valid to glue together discrete frames of MP3. However, many media players will not cope if the frames have different basic encoding settings (especially frequency and channels/mode).

You should also remove any ID3 tags from the files (both versions: ID3v1 from the end and ID3v2 from the start) as these are not valid MP3 data, and ensure that the files do start and end on a frame boundary. Most players will skip over invalid data looking for the next frame as indicated by the MP3 sync word, but Flash may be more picky especially when they are unexpectedly in the middle of the file.

bobince
Thanks for input! Didn't work though, I tried with different mp3's and no ID3 info, but no luck. Had to read the files individually.
Björn