Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modularized #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions flash/Webcam.as
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
private var bmpdata:BitmapData;
private var jpeg_quality:int;
private var image_format:String;
private var external_interface_method:String;

public function Webcam() {
// class constructor
Expand All @@ -50,6 +51,7 @@
dest_height = Math.floor( flashvars.dest_height );
jpeg_quality = Math.floor( flashvars.jpeg_quality );
image_format = flashvars.image_format;
external_interface_method = flashvars.external_interface_method;

stage.scaleMode = StageScaleMode.NO_SCALE;
// stage.scaleMode = StageScaleMode.EXACT_FIT;
Expand Down Expand Up @@ -95,11 +97,11 @@
ExternalInterface.addCallback('_snap', snap);
ExternalInterface.addCallback('_configure', configure);

ExternalInterface.call('Webcam.flashNotify', 'flashLoadComplete', true);
ExternalInterface.call(external_interface_method, 'flashLoadComplete', true);
}
else {
trace("You need a camera.");
ExternalInterface.call('Webcam.flashNotify', "error", "No camera was detected.");
ExternalInterface.call(external_interface_method, "error", "No camera was detected.");
}
}

Expand All @@ -110,7 +112,7 @@

private function activityHandler(event:ActivityEvent):void {
trace("activityHandler: " + event);
ExternalInterface.call('Webcam.flashNotify', 'cameraLive', true);
ExternalInterface.call(external_interface_method, 'cameraLive', true);

// now disable motion detection (may help reduce CPU usage)
camera.setMotionLevel( 100 );
Expand All @@ -120,7 +122,7 @@
switch (e.code) {
case 'Camera.Muted': {
trace("Camera not allowed");
ExternalInterface.call('Webcam.flashNotify', "error", "Access to camera denied");
ExternalInterface.call(external_interface_method, "error", "Access to camera denied");
break;
}
case 'Camera.Unmuted': {
Expand Down
50 changes: 50 additions & 0 deletions tests/modularize/_index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
var Webcam = require('../../webcam.js');

function createWebcam(params){

var webcam = new Webcam(params);

// forcing flash to test the uuid flash interface
webcam.swfURL = "../../webcam.swf";

var webcamEl = document.createElement('div');
var result = document.createElement('img');
var button = document.createElement('button');

button.innerHTML = "snap";
button.addEventListener('click', function(){
webcam.snap( function(data_uri) {
result.src = data_uri;
} );
});

document.body.appendChild(result);
document.body.appendChild(button);
document.body.appendChild(webcamEl);

webcam.attach( webcamEl );

};

createWebcam({
force_flash: true,
width: 320,
height: 240,
});

createWebcam({
force_flash: true,
width: 320,
height: 240,
});

createWebcam({
width: 320,
height: 240
});

createWebcam({
width: 640,
height: 480
});

1 change: 1 addition & 0 deletions tests/modularize/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
browserify _index.js -o index.js
13 changes: 13 additions & 0 deletions tests/modularize/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>

<head>

</head>

<body>

<script src="index.js"></script>

</body>

</html>
Loading