blob: 5104cd7f6617d16888666a8bb820694fd5dedbaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/**
* Neave Camera
*
* Copyright (C) 2008 Paul Neave
* http://www.neave.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation at http://www.gnu.org/licenses/gpl.html
*/
package com.neave.media
{
import flash.events.*;
import flash.media.*;
import flash.system.*;
public class NeaveCamera
{
/**
* The requested width of the camera object
*/
static public var CAMERA_WIDTH:int = 480;
/**
* The requested height of the camera object
*/
static public var CAMERA_HEIGHT:int = 360;
static private var cam:Camera;
public function NeaveCamera() { }
/**
* Sets up and returns the camera object
*
* @return A camera object
*/
static public function getCamera():Camera
{
// Return the same camera if it has been successfully requested before
if (cam != null)
{
if (cam.muted) Security.showSettings(SecurityPanel.PRIVACY);
return cam;
}
// Get the camera
cam = Camera.getCamera();
if (cam != null)
{
// Set properties if a camera was found
cam.setMode(CAMERA_WIDTH, CAMERA_HEIGHT, 30, true);
cam.addEventListener(StatusEvent.STATUS, NeaveCamera.statusListener);
return cam;
}
else
{
// No camera found
Security.showSettings(SecurityPanel.CAMERA);
return new Camera();
}
}
/**
* Whether the camera object is available or not
*/
static public function get muted():Boolean
{
return cam == null || cam.muted || cam.name == null || cam.width == 0;
}
/**
* Camera status response
*/
static private function statusListener(e:StatusEvent):void
{
if (e.code == "Camera.Unmuted") Security.showSettings(SecurityPanel.CAMERA);
}
}
}
|