Add highlighted code to the MyNetConnection.
public function onConnect(event:NetStatusEvent):void { client = new MyNetConnectionClient(); setupPingTimer(); }
Then create MyNetConnectionClient. This is a publisher side code.
package my.project.flash { public class MyNetConnectionClient { private var camera:Camera; private var microphone:Microphone; private var nsPublish:NetStream; public function MyNetConnectionClient(netConnection:NetConnection) { camera = Camera.getCamera(); microphone = Microphone.getMicrophone(); nsPublish = new NetStream(netConnection); nsPublish.publish("myPublishStreamId"); nsPublish.attachCamera(camera); nsPublish.attachAudio(microphone); microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, nsPublishSampleAudioFrame); } public function nsPublishSampleAudioFrame(event:SampleDataEvent):void { var metaData:Object = new Object(); metaData.audioActivityLevel = microphone.activityLevel; nsPublish.send("setAudioActivityLevel", metaData); } } }
Then the player side client code. "setAudioActivityLevel" should be the method on a NetStream.client. So you can have audio activity level per stream.
var stream:Stream = new NetStream(); stream.client = new MyNetStreamClient(); stream.play("myPublishStreamId");
package my.project.flash { public class MyNetStreamClient { public function setAudioActivityLevel(param:Object):void { doSomethingToShowAutioActivityLevel(param.audioActivityLevel); } } }
Hmmm, I changed a lot from my source code, and I do not check it. So I'm not sure it works or not. However, I hope this will give you some hints.
No comments:
Post a Comment