Skip to main content
Known Participant
January 25, 2010
Question

Stream AAC audio file stored locally using NetStream class

  • January 25, 2010
  • 1 reply
  • 1523 views

Hello,

(sorry  for my English, it sucks!)

I would like use NetStream class to stream AAC audio file stored locally on server (because i can't use Sound class, AAC not compatible)

How can i do this ? (without flash media server)

Is it possible ?

I have tried using http protocol, no errors occured, but i receive no audio data.

Thanks for your help

Best regards, fabien.

This topic has been closed for replies.

1 reply

Inspiring
January 25, 2010

You cannot stream anything without a server side. But you can download file progressively and start playing is as soon as sufficient data is available. How did you try to access the file in Flash?

hightonAuthor
Known Participant
January 25, 2010

Like this :

## BEGIN


var streamURL:String = "instru-53453.mp3"; //file is sotred in the same directory of swf

function netStatusHandler(event:NetStatusEvent) {
    switch (event.info.code) {
        case "NetConnection.Connect.Success":
            trace('Connect Success');
            break;
        case "NetStream.Play.StreamNotFound":
            trace("Stream not found");
            break;
    }
}

function connectStream():void {
    var stream:NetStream = new NetStream(connection);
    stream.client = this;
    stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

    stream.play(streamURL);

    //I also tried this
    //var request:URLRequest = new URLRequest(streamURL);
    //stream.play(request);
}

var connection:NetConnection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
connection.connect(null);
   
connectStream();

## END

I try  yet with mp3s...

Thanks for your help.


Inspiring
January 25, 2010

I don't believe mp3 can be handled this way. You said your audio file is AAC - so it must have some other extension like .m4a (and corresponding codec)

With mp3 you need to use Sound class in conjunction with URLRequest and SoundChannel classes.