动作3:监视活动水平为多个麦克风似乎不工作多个、麦克风、水平、动作

2023-09-08 14:03:13 作者:烟伤肺不伤心

对于一个项目,我想显示所有可用的网络摄像头和麦克风,让用户可以轻松选择任何摄像头/麦克风组合,他们preFER。我碰到一个问题,麦克风上市,但。

For a project I want to show all available webcams and microphones, so that the user can easily select whichever webcam/microphone combination they prefer. I run into an issue with the microphones listing though.

每个麦克风都列出了活动的动画和它的名字。我能列出所有麦克风就好了(使用Microphone.names阵列),但似乎我只能得到观众的活动,以工作的一个麦克风。另一个麦克风显示了-1的活动,其中(据我所知)是Flex来'present,但不使用。当拔下麦克风的确实的演出活动,下一个(在我的情况下,麦克风输入我的主板就行)显示了0活动(它没有连接,所以这是有道理的)

Each microphone is listed with an activity animation and it's name. I am able to list all Microphones just fine (using the Microphone.names Array), but it seems like I can only get the activity viewer to work for one microphone. The other microphones show up with '-1' activity, which (as far as I know) is Flex for 'present, but not in use'. When unplugging the microphone that does show activity, the next one (in my case, the mic-in line on my motherboard) shows up with '0' activity (it's not connected, so that makes sense).

在我的测试中,我总共有3麦克风可用,不连接的板载麦克风输入端口,以及两个连接的麦克风。

During my testing I have a total of 3 microphones available, the not-connected onboard mic-in port, and two connected microphones.

为了测试我使用了一个定时器,跟踪当前麦克风的活动每个100毫秒和图表也显示。

For testing purposes I use a timer that traces the current microphone activity each 100ms and the graph is also shown.

这似乎没有什么重要默认麦克风我用快速的设置面板中设置。

It does not seem to matter what default microphone I set via flash' settings panel.

的code

我只附着在revelant code以下片段,使你更容易阅读它们。请让我知道如果你preFER整个code。

I've only attached the revelant code snippets below to make it easier for you to read through them. Please let me know if you prefer the entire code.

主要application.mxml

注:续是一个垂直框。我是这样code段之前定义的。的

var mics:Array = Microphone.names;
for(i=0; i < mics.length; i++){
   var mic:settingsMicEntry = new assets.settingsMicEntry;
   mic.d = {name: mics[i], index: i};

   cont.addChild(mic);
}

资产/ settingsMicEntry.mxml

定时器此code段之前定义。以将SoundTransform加入到沉默本地麦克风回放。扣除这code没有解决问题,遗憾的是(我试过)。显示器是一个MXML Canvas对象。的

mic = Microphone.getMicrophone(d.index);
if(mic){
    // Temporary: The Microphones' visualizer
   var bar:Box = new Box();
   bar.y = 50;
   bar.height = 0;
   bar.width = 66;
   bar.setStyle("backgroundColor", 0x003300);
   display.addChild(bar);

   var tf:SoundTransform = new SoundTransform(0);
   mic.setLoopBack(true);
   mic.soundTransform = tf;

   timer = new Timer(100);
   timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void{
      var h:int = Math.floor((display.height/100)*mic.activityLevel);

      bar.height = (h>-1) ? h : 0;
      bar.y = (h>-1) ? display.height-h : display.height;

      trace('TIMER: '+h+' from '+d.name);
   });
   timer.start();
}

我拉我听得出在这里,所以任何帮助深表AP preciated!

I'm pulling my hear out here, so any help is much appreciated!

谢谢

戴夫

诗:赦免code中的混乱!的

推荐答案

您可以使用的 OSMF 库。

您需要导入从NetMocker项目类(在库/土坯 - org.osmf.netmocker)和类的NetConnection codeS和NetStream codeS(下框架/ OSMF - org.osmf .NET)。

You'll need to import the classes from the NetMocker project (under libs/adobe - org.osmf.netmocker) and the classes NetConnectionCodes and NetStreamCodes (under framework/OSMF - org.osmf.net).