hanbaojun 2008-7-3 09:59
有没办法从 NetStream 或视频组件中获取 Microphone 对象?
或者从 视频组件获取也行?
代码:
ns = NetStream(nc)
video.attchVideo(ns);
video.attchAudio(ns);
var mic:Microphone = ?
有没办法从 ns 或 video 中生成一个 Microphone 对象?
这样做是想利用流中的声音的大小生成一个简单的可视化条形图。
声音小时图形宽度就小,反之就大,像UC聊天室说话时的那个图形。
终极讨厌 2008-7-3 10:08
不可以,AS3也不可以
但让流中的声音可视化是可以的
终极讨厌 2008-7-3 13:58
[quote]原帖由 [i]hanbaojun[/i] 于 2008-7-3 12:40 发表 [url=http://space.flash8.net/bbs/redirect.php?goto=findpost&pid=2194655&ptid=357390][img]http://space.flash8.net/bbs/images/common/back.gif[/img][/url]
让流中的声音可视化,要怎么实现?
谢谢! [/quote]
AS3:[code]var p_bytearray:ByteArray =new ByteArray;
var p_nc:NetConnection =new NetConnection;
p_nc.connect(null);
var p_ns:NetStream =new NetStream(p_nc);
var wave_sprite:Sprite=new Sprite;
wave_sprite.x=200,wave_sprite.y=360;
addChild(wave_sprite);
function showWave(_evt:Event):void {
SoundMixer.computeSpectrum(p_bytearray,false);
wave_sprite.graphics.clear();
for (var _p:uint =0; _p<32; _p++) {
var _num:Number =p_bytearray.readFloat()*100;
_num=_num>0?-uint(_num):0;
wave_sprite.graphics.lineStyle(5,uint(Math.random ()*0xFFFFFF));
wave_sprite.graphics.moveTo(_p*6,0);
wave_sprite.graphics.lineTo(_p*6,_num);
p_bytearray.position +=16;
}
}
function onMetaData(_obj:Object):void {
wave_sprite.addEventListener("enterFrame",showWave);
}
p_ns.client =this;
p_video.attachNetStream(p_ns);
p_ns.play("video.flv");[/code]
关于 SoundMixer.computeSpectrum的详细使用情况及注意事项,请看帮助文档。
以下示例文件是CS3的,FLASH8打不开。