start showing some hints to the user about the camera, such as errors when the camera could not be opened, if there is no camera connected, among other things; if it is OK, it will be needed to extract the strings to the localization file
This commit is contained in:
parent
69f7ca7aa4
commit
feb57b6e8e
@ -74,6 +74,7 @@
|
||||
// any activity on the camera. It avoids the problem of publishing
|
||||
// a blank video
|
||||
private var _activationTimer:Timer = null;
|
||||
private var _waitingForActivation:Boolean = false;
|
||||
|
||||
[Bindable]
|
||||
public var videoOptions:VideoConfOptions;
|
||||
@ -108,7 +109,7 @@
|
||||
autoPublishTimer.start();
|
||||
}
|
||||
|
||||
// start a preview
|
||||
// start the camera preview
|
||||
updateCamera();
|
||||
}
|
||||
|
||||
@ -129,22 +130,27 @@
|
||||
stopCamera();
|
||||
|
||||
btnStartPublish.enabled = false;
|
||||
|
||||
if (Camera.names.length == 0) {
|
||||
showWarning("No camera available");
|
||||
return;
|
||||
}
|
||||
|
||||
_camera = Camera.getCamera(cmbCameraSelector.selectedIndex.toString());
|
||||
if (_camera == null) {
|
||||
LogUtil.debug("Can't open your camera, it probably is being used by another application");
|
||||
showWarning("Can't open your camera");
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtil.debug("Opened camera: " + _camera.name);
|
||||
_camera.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
|
||||
|
||||
// set timer to ensure that the camera activates. If not, it might be in use by another application
|
||||
_waitingForActivation = true;
|
||||
if (_activationTimer != null)
|
||||
_activationTimer.stop();
|
||||
_activationTimer = new Timer(5000, 1);
|
||||
_activationTimer.addEventListener(TimerEvent.TIMER, activationTimeout);
|
||||
_activationTimer.start();
|
||||
LogUtil.debug("Starting activation timer");
|
||||
|
||||
setComboResolution();
|
||||
|
||||
@ -176,20 +182,24 @@
|
||||
}
|
||||
|
||||
private function activityHandler(e:ActivityEvent):void {
|
||||
if (e.activating) {
|
||||
if (_waitingForActivation && e.activating) {
|
||||
_activationTimer.stop();
|
||||
showWarning("Video preview", false, "0xFFFF00");
|
||||
btnStartPublish.enabled = true;
|
||||
LogUtil.debug("Enabling start publishing button");
|
||||
_waitingForActivation = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function activationTimeout(e:TimerEvent):void {
|
||||
LogUtil.debug("There's no activity in your camera, so probably it is being used by another application");
|
||||
showWarning("Your camera is being used by another application");
|
||||
updateCamera();
|
||||
}
|
||||
|
||||
private function startPublishing():void{
|
||||
if (_camera == null) return;
|
||||
|
||||
showWarning("Publishing...", true, "0xFFFF00");
|
||||
|
||||
defaultWidth = originalWidth;
|
||||
defaultHeight = originalHeight;
|
||||
|
||||
@ -233,8 +243,8 @@
|
||||
_video.attachCamera(null);
|
||||
_video.clear();
|
||||
_video = null;
|
||||
_camera = null;
|
||||
}
|
||||
_camera = null;
|
||||
}
|
||||
|
||||
private function stopPublishing():void{
|
||||
@ -283,7 +293,6 @@
|
||||
btnStartPublish.visible = false;
|
||||
cmbCameraSelector.visible = false;
|
||||
videoOptionsBar.visible = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,10 +324,36 @@
|
||||
override protected function resourcesChanged():void{
|
||||
super.resourcesChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private var hideWarningTimer:Timer = null;
|
||||
|
||||
private function showWarning(text:String, autoHide:Boolean=false, color:String="0xFF0000"):void {
|
||||
if (hideWarningTimer != null)
|
||||
hideWarningTimer.stop();
|
||||
if (autoHide) {
|
||||
hideWarningTimer = new Timer(3000, 1);
|
||||
hideWarningTimer.addEventListener(TimerEvent.TIMER, hideWarning);
|
||||
hideWarningTimer.start();
|
||||
}
|
||||
|
||||
// bring the label to front
|
||||
setChildIndex(lblWarning, getChildren().length - 1);
|
||||
lblWarning.text = text;
|
||||
lblWarning.setStyle("color", color);
|
||||
lblWarning.visible = true;
|
||||
}
|
||||
|
||||
private function hideWarning(e:TimerEvent):void {
|
||||
lblWarning.visible = false;
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:Fade id="dissolveOut" duration="1000" alphaFrom="1.0" alphaTo="0.0"/>
|
||||
<mx:Fade id="dissolveIn" duration="1000" alphaFrom="0.0" alphaTo="1.0"/>
|
||||
<mx:Text id="lblWarning" width="100%" textAlign="right" fontSize="14" fontWeight="bold" y="{this.height - (videoOptionsBar.visible? videoOptionsBar.height: 0) - lblWarning.height - 30}" visible="false" selectable="false" hideEffect="{dissolveOut}" showEffect="{dissolveIn}"/>
|
||||
<mx:ControlBar id="videoOptionsBar" visible="true">
|
||||
<mx:Button id="btnStartPublish" toolTip="{ResourceUtil.getInstance().getString('bbb.publishVideo.startPublishBtn.toolTip')}" icon="{camIcon}" click="startPublishing()" enabled="false"/>
|
||||
<mx:ComboBox id="cmbCameraSelector" dataProvider="{Camera.names}" width="150" visible="false" change="updateCamera()"/>
|
||||
|
Loading…
Reference in New Issue
Block a user