NetStream.seek可以移动MP3的播放头吗? [英] Can NetStream.seek move the playhead of an MP3?

查看:118
本文介绍了NetStream.seek可以移动MP3的播放头吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义SWF来播放使用RTMP和<NetStream>的MP3.我能够连接到服务器,播放和暂停mp3,并使用<SoundTransform>调节音量.但是我仍然无法从<NetStream>检索元数据来创建搜索栏.

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.

<NetStream.seek>可以移动流式mp3文件的播放头吗?

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

推荐答案

要制作搜索栏,您必须知道mp3的长度(持续时间).为此,您可以使用 getStreamLength 服务器端函数,可以像这样在连接后调用:

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.

希望可以提供帮助.

这篇关于NetStream.seek可以移动MP3的播放头吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆