Looping and manipulating AAC/m4a streams

Hi, thanks for reading my first post on this forum.

i’m trying to (seamlessly) loop a AAC audio file. It seems to be impossible. I’m trying this because it is impossible to seamlessly loop a MP3 due to its nature.

I succeeded in just playing the m4a file like this:


_nc = new NetConnection();
_nc.connect(null);
_nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
            
_ns = new NetStream(_nc);
_ns.play(_url);

trouble is you’re playing a netstream. You can listen for the playing going ‘stop’ and subsequently re-play the URL or do a _ns.seek(0) but this will produce a short silence in the loop. You could also listen for the buffer going ‘FLUSH’ which should give you enough time to reconnect to the stream and append it to the buffer, however if you call _ns.play() (or any variation of _ns.play2()) it will interrupt the old stream before it’s finished.

Also, it seems to be impossible to put a m4a inside a Sound object. (I tried reading the m4a into a ByteArray (using URLStream) and feeding it to a Sound object (using SampleDataEvent). Nu luck.)

The only thing I can imagine is to play the stream as mentioned above and using the SoundMixer.computeSpectrum() and storing that data into a byteArray…but that would mean I have to ‘render’ all my audio before I can loop it.

so… suggestions anybody on how to loop a AAC file?