I am recording from a webcam to AMS in an AS3 project and to get the volume level from the microphone I have to attach the microphone to a NetStream. Later when the user initiates recording the NetStream.time value counts from when the camera was attached and not from when NetStream.publish was called. If they stop the recording and record again, now NetStream.time starts from 0. So far the only way to get round this seems to be call publish and then close on the NetStream as soon as the microphone is attached. The docs for AS2 NetStream mention this fact and suggest to call NetStream.publish(false) which doesn't work in AS3, neither does just calling publish with no args.
ns = new NetStream(nc);
ns.attachCamera(cam);
ns.attachAudio(mic);
Then later
ns.publish(filename,"record");
trace(ns.time);
is the elapsed time between attaching the camera and calling publish for the first time.
The only solution I have so far is
ns = new NetStream(nc);
ns.attachCamera(cam);
ns.attachAudio(mic);
ns.publish(filename,"record");
ns.close();
the when the user starts the reording
ns.publish(filename,"record");
trace(ns.time);
ns.time is now zero. Am I missing something, is there a better solution?