/sitios/com/ui/controllers/mvc/webcam/BasicWebcamModel.as

https://bitbucket.org/simkinjerkin/simkinfw
ActionScript | 183 lines | 125 code | 34 blank | 24 comment | 1 complexity | 7a6151a0b62496646047c0d1b3be8d03 MD5 | raw file
  1. package com.ui.controllers.mvc.webcam {
  2. import com.ui.controllers.mvc.BasicFormStates;
  3. import com.ui.controllers.mvc.interfaces.IModel;
  4. import com.ui.controllers.mvc.models.BasicModel;
  5. import com.utils.graphics.DisplayContainer;
  6. import flash.display.Bitmap;
  7. import flash.display.DisplayObject;
  8. import flash.display.DisplayObjectContainer;
  9. import flash.display.Sprite;
  10. import flash.media.Camera;
  11. import flash.media.Video;
  12. public class BasicWebcamModel extends BasicModel implements IModel {
  13. protected var _videoContainer:DisplayObjectContainer;
  14. protected var _automaticStart:Boolean = false;
  15. protected var _serverURL:String = null;
  16. protected var _fileName:String = null;
  17. protected var _capturedImage:DisplayObject;
  18. protected var _videoWidth:uint = 320;
  19. protected var _videoHeight:uint = 240;
  20. protected var _fps:uint = 12;
  21. protected var _useCamera:Boolean = false;
  22. protected var _recordTime:Number;
  23. protected var _micEnabled:Boolean = true;
  24. protected var _videoQuality:Number = 90;
  25. protected var _webCamera:Camera;
  26. protected var _video:Video;
  27. public function set video($value:Video):void {
  28. _video = $value;
  29. }
  30. public function get video():Video {
  31. return _video;
  32. }
  33. public function set automaticStart($value:Boolean):void {
  34. _automaticStart = $value;
  35. }
  36. public function get automaticStart():Boolean {
  37. return _automaticStart;
  38. }
  39. public function set videoContainer($value:DisplayObjectContainer):void {
  40. _videoContainer = $value;
  41. }
  42. public function get videoContainer():DisplayObjectContainer {
  43. return _videoContainer;
  44. }
  45. public function set capturedImage($value:DisplayObject):void {
  46. _capturedImage = $value;
  47. if($value) {
  48. setState(BasicWebcamStates.ON_IMAGE_CAPTURED);
  49. setState(BasicFormStates.FINISHING);
  50. }
  51. }
  52. public function get capturedImage():DisplayObject {
  53. return _capturedImage;
  54. }
  55. public function set webCamera($value:Camera):void {
  56. _webCamera = $value;
  57. }
  58. public function get webCamera():Camera {
  59. return _webCamera;
  60. }
  61. /**
  62. * Configura el servidor al que se enviara la conexión
  63. * @param $server
  64. */
  65. public function set serverURL($URL:String):void {
  66. _serverURL = $URL;
  67. }
  68. public function get serverURL():String {
  69. return _serverURL;
  70. }
  71. /**
  72. * Configura el nombre que tendra el archivo.
  73. * @param $fileName
  74. */
  75. public function set fileName($fileName:String):void {
  76. _fileName = $fileName;
  77. }
  78. public function get fileName():String {
  79. return _fileName;
  80. }
  81. /**
  82. * Configura el ancho del video
  83. * @param $value
  84. */
  85. public function set videoWidth($value:Number):void {
  86. _videoWidth = $value;
  87. }
  88. public function get videoWidth():Number {
  89. return _videoWidth;
  90. }
  91. /**
  92. * Configura el alto del video
  93. * @param $value
  94. */
  95. public function set videoHeight($value:Number):void {
  96. _videoHeight = $value;
  97. }
  98. public function get videoHeight():Number {
  99. return _videoHeight;
  100. }
  101. /**
  102. * Configura el número de frames por segundo
  103. * @param $value
  104. */
  105. public function set fps($value:uint):void {
  106. _fps = $value;
  107. }
  108. public function get fps():uint {
  109. return _fps;
  110. }
  111. public function set useCamera($value:Boolean):void {
  112. _useCamera = $value;
  113. }
  114. public function get useCamera():Boolean {
  115. return _useCamera;
  116. }
  117. /**
  118. * Tiempo de grabación
  119. * @param $value
  120. */
  121. public function set recordTime($value:Number):void {
  122. _recordTime = $value;
  123. }
  124. public function get recordTime():Number {
  125. return _recordTime;
  126. }
  127. public function set micEnabled($value:Boolean):void {
  128. _micEnabled = $value;
  129. }
  130. public function get micEnabled():Boolean {
  131. return _micEnabled;
  132. }
  133. public function set videoQuality($value:Number):void {
  134. _videoQuality = $value;
  135. }
  136. public function get videoQuality():Number {
  137. return _videoQuality;
  138. }
  139. public function BasicWebcamModel() {
  140. super();
  141. }
  142. override protected function getErrorPhrase($ID:String):String {
  143. switch($ID){
  144. case BasicWebcamStates.ON_CAMERA_ERROR: return "Necesitas webcam para realizar una imagen directa.";
  145. }
  146. return "Error de tipo: " + $ID;
  147. }
  148. }
  149. }