I'm building a video chat in flash and everything works really well, except for the part where I'm trying to detect if the other user is sending a working video stream.
There's a couple of reasons why the other user isn't sending video.
- The other user got no camera
- The other user got a camera, but the camera is currently being occupied by another application(Skype, Photo Booth, Google Talk, etc.)
- The other user got a camera but hasn't allowed the use of his/hers camera.
- (Other unexpected problems I guess...)
So how do I detect if the stream I receive from the other user is a black stream(because of the reasons above) using the NetStream class?
The closest thing I have came up with is by adding a timer that polls the currentFps() function from the stream I receive from the other user. But so far this seems pretty unreliable because I might get currentFps() == 0
and show an error because of this even though I actually got video from the stream in some cases. The reason for this is because I poll the API every 4 seconds for the currentFPS function and let's say at 00:00:04 I get "no video" according to the poll but at 00:00:05 the video kicks in, and therefor I need to wait until the next tick until the error message disappears
This is what my current poll looks like
function subscribingStatusPoll(e:TimerEvent):void {
if (subscribingStream.currentFPS == 0){
error.text = "No video found from the other user..."
} else {
error.text = "";
}
}
This is the only hack I that I can come up with to detect this, but this is unreliable and I actually would prefer a way to instantly detect if the stream I receive got a working video attached to it without this ugly poll.