问题
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:
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.
来源:https://stackoverflow.com/questions/28754848/can-netstream-seek-move-the-playhead-of-an-mp3