Can NetStream.seek move the playhead of an MP3?

微笑、不失礼 提交于 2019-12-13 01:55:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!