R – Playing concatinated mp3 files through flash with as3

actionscript-3flash

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();
    }
...

Best Answer

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).

Related Topic