1

I create a custom SWF to play MP3s that use RTMP and <NetStream>. I was able to connect to the server, play and pause the mp3, and adjust the volume using <SoundTransform>. But I still can't retrieve metadata from the <NetStream> to make a seek bar.

Can <NetStream.seek> move the playhead of an streaming mp3 file?

1 Answer 1

1

To make a seek bar, you have to know the length (duration) of your mp3. To get that, you can use the getStreamLength server side function which you can call after been connected like this :

var nc:NetConnection = new NetConnection();
const stream:String = 'mp3:mp3_file';   // mp3_file.mp3

// all other declarations, initializations and the connection to the server

// after receiving NetConnection.Connect.Success    
var responder:Responder = new Responder(function(duration:Object){
    trace('mp3 duration : ', duration);
})
nc.call('getStreamLength', responder, stream);

After receiving the duration, you can draw your seek bar.

For more informations, you can take a look here.

Hope that can help.

1
  • This worked perfectly. Before, I tried to get the metedata by netstream.client.duration but the server side script work like a charm.
    – JRShel
    Mar 2, 2015 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.