I wan't to create a Skype-like experience where two persons can communicate by video/audio. Now I want to be able to turn off the video or the audio on the receiving side, meaning I not only want to not display the video or turn down the volume of the audio on the stream, I wan't to make sure the client doesn't stream the data (to save bandwidth). Is this possible?
Let me give an example of what I'm doing now.
Host
var stream:NetStream = new NetStream(connection);
stream.attachCamera(camera);
stream.attachAudio(microphone);
stream.publish('myStream');
Client
var stream:NetStream = new NetStream(connection);
var stream.play('myStream');
On the client I would love if there was a way to tell the stream to detach the video or the audio, like you can attach them on the host side. Something like: stream.detachAudio()
Please let me know if I'm going about this the wrong way or there's a different way to achieve this.
For that, you can use NetStream.receiveVideo
and NetStream.receiveAudio
like this :
ns.receiveVideo(true); // to receive the video stream
ns.receiveVideo(false); // to stop receiving the video stream
And
ns.receiveAudio(true); // to receive the audio stream
ns.receiveAudio(false); // to stop receiving the audio stream
Of course you can verify that you are not receiving video or audio stream using NetStream.info
:
trace('ns.videoBytesPerSecond : ' + ns.info.videoBytesPerSecond);
trace('ns.audioBytesPerSecond : ' + ns.info.audioBytesPerSecond);
Hope that can help.