Jpegcam, disable capture button after access denied

In my php project, I used jpegcam, http://code.google.com/p/jpegcam/ and when we load the webcam capture page, it asks for permission to allow or deny the flash player, even if I denied that the option capture button is on. I want to disable the capture button when it loads and turns on only if the user allows permissions!

So, how to verify that the user has allowed or denied access to webcams in the privacy settings dialog for the site? ! Guys, any help would be appreciated .. :)

+5
source share
1 answer

The ActionScript property Camera.mutedis what you need. The source you contacted creates a private object Camerawith a name Camera. You can make it public or add a new method to check its property muted;

final public function has_access( ) : Boolean {
    return !camera.muted;
}

As a rule, you should hide / disable the button until the muting is false (it is very unlikely that it will again become true, the user will have to manually open the settings window and disable access).

You can also use a listener to avoid constantly checking this value;

final public function add_access_listener( myFunc : Function ) : void {
    camera.addEventListener( "status", myFunc ); // StatusEvent.STATUS
}

What will be used as follows:

myWebcam.add_access_listener( myAccessFunc );
function myAccessFunc( ev : StatusEvent ) : void {
    if( ev.code == "Camera.Unmuted" ) {
        // video became available, enable button
    } else {
        // video became unavailable, disable button
    }
}
// remember that the user could have granted persistent permission
// (i.e. the status will be unmuted without actually changing)
if( myWebcam.has_access( ) ) {
    // video is already available, enable button
} else {
    // video is not yet available, disable button
}

To avoid possible memory leaks, you should also call removeEventListenerif you ever remove the camera, but the library does not seem to be designed for this, and in any case (and does not delete its own listeners).

0

All Articles