Merge pull request #917 from edx/ormsbee/check_flash_video_permissions
Check flash video permissions before enabling next step
This commit is contained in:
@@ -18,11 +18,13 @@ package
|
||||
import flash.display.PNGEncoderOptions;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.StatusEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.media.Camera;
|
||||
import flash.media.Video;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
import mx.utils.Base64Encoder;
|
||||
|
||||
[SWF(width="640", height="480")]
|
||||
@@ -35,15 +37,17 @@ package
|
||||
private var camera:Camera;
|
||||
private var video:Video;
|
||||
private var b64EncodedImage:String = null;
|
||||
private var permissionGiven:Boolean = false;
|
||||
|
||||
public function CameraCapture()
|
||||
{
|
||||
addEventListener(Event.ADDED_TO_STAGE, init);
|
||||
addEventListener(Event.ADDED_TO_STAGE, init);
|
||||
}
|
||||
|
||||
protected function init(e:Event):void {
|
||||
camera = Camera.getCamera();
|
||||
camera.setMode(VIDEO_WIDTH, VIDEO_HEIGHT, 30);
|
||||
camera.addEventListener(StatusEvent.STATUS, statusHandler);
|
||||
|
||||
video = new Video(VIDEO_WIDTH, VIDEO_HEIGHT);
|
||||
video.attachCamera(camera);
|
||||
@@ -53,6 +57,7 @@ package
|
||||
ExternalInterface.addCallback("snap", snap);
|
||||
ExternalInterface.addCallback("reset", reset);
|
||||
ExternalInterface.addCallback("imageDataUrl", imageDataUrl);
|
||||
ExternalInterface.addCallback("cameraAuthorized", cameraAuthorized);
|
||||
|
||||
// Notify the container that the SWF is ready to be called.
|
||||
ExternalInterface.call("setSWFIsReady");
|
||||
@@ -98,6 +103,24 @@ package
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function cameraAuthorized():Boolean {
|
||||
return permissionGiven;
|
||||
}
|
||||
|
||||
public function statusHandler(event:StatusEvent):void {
|
||||
switch (event.code)
|
||||
{
|
||||
case "Camera.Muted":
|
||||
// User clicked Deny.
|
||||
permissionGiven = false;
|
||||
break;
|
||||
case "Camera.Unmuted":
|
||||
// "User clicked Accept.
|
||||
permissionGiven = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -124,7 +124,12 @@ function initSnapshotHandler(names, hasHtml5CameraSupport) {
|
||||
video[0].pause();
|
||||
}
|
||||
else {
|
||||
image[0].src = flashCapture[0].snap();
|
||||
if (flashCapture[0].cameraAuthorized()) {
|
||||
image[0].src = flashCapture[0].snap();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
doSnapshotButton(captureButton, resetButton, approveButton);
|
||||
@@ -186,7 +191,7 @@ function initSnapshotHandler(names, hasHtml5CameraSupport) {
|
||||
function objectTagForFlashCamera(name) {
|
||||
return '<object type="application/x-shockwave-flash" id="' +
|
||||
name + '" name="' + name + '" data=' +
|
||||
'"/static/js/verify_student/CameraCapture.swf"' +
|
||||
'"/static/js/verify_student/CameraCapture.swf?v=2"' +
|
||||
'width="500" height="375"><param name="quality" ' +
|
||||
'value="high"><param name="allowscriptaccess" ' +
|
||||
'value="sameDomain"></object>';
|
||||
|
||||
Reference in New Issue
Block a user