resolutions are configurated by the config.xml; removed the close button from PublishWindow; implemented the maximize and restore; corrected the implementation of resizing; the implementation of maximize, restore and resize is exactly the same for both PublishWindow and VideoWindow

This commit is contained in:
Felipe Cecagno 2011-03-03 23:30:27 +00:00 committed by Marco Calderon
parent 01a5490421
commit 1c389f01d3
5 changed files with 198 additions and 64 deletions

View File

@ -56,6 +56,7 @@
dependsOn="ViewersModule"
videoQuality="70"
presenterShareOnly="false"
resolutions="160x120,320x240,640x480,1280x720"
/>
<module name="WhiteboardModule" url="WhiteboardModule.swf?v=VERSION"

View File

@ -68,6 +68,10 @@
return Number(_attributes.videoQuality);
}
public function get resolutions():String {
return _attributes.resolutions;
}
public function get presenterShareOnly():Boolean{
if (_attributes.presenterShareOnly == "true") return true;
else return false;

View File

@ -56,6 +56,7 @@
if (userid == module.userid) return;
var window:VideoWindow = new VideoWindow();
window.resolutions = module.resolutions.split(",");
if (mock) {
window.startVideo(module.mockConnection, stream);
@ -64,7 +65,6 @@
window.startVideo(module.connection, stream);
}
window.title = name;
var windowEvent:OpenWindowEvent = new OpenWindowEvent(OpenWindowEvent.OPEN_WINDOW_EVENT);
windowEvent.window = window;
globalDispatcher.dispatchEvent(windowEvent);
@ -91,6 +91,7 @@
publishWindow.streamName = module.userid.toString();
publishWindow.userrole = module.role;
publishWindow.quality = module.quality;
publishWindow.resolutions = module.resolutions.split(",");
var windowEvent:OpenWindowEvent = new OpenWindowEvent(OpenWindowEvent.OPEN_WINDOW_EVENT);
windowEvent.window = publishWindow;

View File

@ -25,10 +25,9 @@
xmlns:pubVid="flexlib.mdi.containers.*"
implements="org.bigbluebutton.common.IBbbModuleWindow"
creationComplete="init()"
width="{camWidth + 6}" height="{camHeight + 73}"
width="{camWidth + 6}" height="{camHeight + 75}"
title="{ResourceUtil.getInstance().getString('bbb.publishVideo.title')}"
backgroundImage="{bbbLogo}"
resizable="false"
xmlns:mate="http://mate.asfusion.com/">
<mx:Script>
@ -39,6 +38,7 @@
import mx.events.ResizeEvent;
import org.bigbluebutton.common.Images;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.videoconf.events.CloseAllWindowsEvent;
import org.bigbluebutton.modules.videoconf.events.StartBroadcastEvent;
@ -48,7 +48,7 @@
private var images:Images = new Images();
[Bindable] public var camIcon:Class = images.control_play;
[Bindable] public var bbbLogo:Class = images.bbb_logo;
[Bindable] private var resolutions:Array = new Array("320x240", "640x480");
[Bindable] public var resolutions:Array = new Array("320x240", "640x480");
private var video:Video;
public var streamName:String;
@ -57,14 +57,28 @@
private var _userrole:String;
public var quality:Number = 0;
private var _bResizePossible:Boolean = true;
private var _nAspectRatio:Number = 1;
private var _nSavedVideoWidth:Number;
private var _nSavedVideoHeight:Number;
private function init():void{
currentState = "dispVideoOptionsControlBar";
checkIfMacCamera();
if (isPresenter()) showResControls(true);
if (Camera.names.length > 1) showVideoControls(true);
if (!isPresenter() && Camera.names.length == 1) startPublishing();
addEventListener(MDIWindowEvent.RESIZE_END, onResizeEvent);
addEventListener(MDIWindowEvent.RESIZE, onResizeEvent);
addEventListener(MDIWindowEvent.MAXIMIZE, onMaximize);
addEventListener(MDIWindowEvent.RESTORE, onRestore);
this.minWidth = 166;
this.minHeight = 149;
maximizeRestoreBtn.visible = false;
this.resizable = false;
}
public function getPrefferedPosition():String{
@ -85,6 +99,7 @@
//Next two lines may seem redundant but they're not. Do not delete.
video.width = camWidth;
video.height = camHeight;
adjustWindowSize();
video.attachCamera(camera);
videoHolder.addChild(video);
// addChild(videoHolder);
@ -96,6 +111,9 @@
showVideoControls(false);
showResControls(false);
maximizeRestoreBtn.visible = true;
this.resizable = true;
}
override public function close(event:MouseEvent=null):void{
@ -115,13 +133,10 @@
}
private function setResolution():void{
if (cmbResolution.selectedLabel == "320x240"){
camHeight = 240;
camWidth = 320;
} else if (cmbResolution.selectedLabel == "640x480"){
camHeight = 480;
camWidth = 640;
}
var res:Array = cmbResolution.selectedLabel.split( "x" );
camWidth = Number(res[0]);
camHeight = Number(res[1]);
_nAspectRatio = (camWidth/camHeight);
this.streamName = cmbResolution.selectedLabel.concat(this.streamName);
}
@ -144,7 +159,7 @@
videoOptionsBar.visible = true;
btnStartPublish.visible = true;
cmbCameraSelector.visible = false;
currentState = "dispQuitControlBar";
currentState = "dispVideo";
}
}
@ -172,6 +187,77 @@
}
}
private function adjustWindowSize():void{
videoHolder.width = video.width;
videoHolder.height = video.height;
this.width = video.width + 6;
this.height = video.height + 29;
}
public function onResizeEvent(event:MDIWindowEvent):void {
if (event.type == MDIWindowEvent.RESIZE) {
// test if we are already resizing
if (_bResizePossible) {
_bResizePossible = false;
resizeWindow();
_bResizePossible = true;
}
} else if (event.type == MDIWindowEvent.RESIZE_END) {
if (this.width > this.parent.width) {
this.width = this.parent.width;
this.height = Math.floor((this.width - 6) / _nAspectRatio) + 29;
}
if (this.height > this.parent.height) {
this.height = this.parent.height;
this.width = (this.height - 29) * _nAspectRatio + 6;
}
// make sure the size of the window is correct
resizeWindow();
}
}
private function resizeWindow():void {
// recalc size of video based on the width and height of the window
// make sure the video has a correct aspect ratio to avoid tall or flat faces
if (this.width == video.width + 6) {
video.height = this.height - 29;
video.width = video.height * _nAspectRatio;
} else {
video.width = this.width - 6;
video.height = Math.floor (video.width / _nAspectRatio);
}
adjustWindowSize();
}
public function onMaximize(event:MDIWindowEvent):void {
_nSavedVideoWidth = video.width;
_nSavedVideoHeight = video.height;
var tmpWidth:Number = this.parent.width - 6;
var tmpHeight:Number = this.parent.height - 29;
if (tmpWidth > tmpHeight * _nAspectRatio)
tmpWidth = tmpHeight * _nAspectRatio;
if (tmpHeight > Math.floor(tmpWidth / _nAspectRatio))
tmpHeight = Math.floor(tmpWidth / _nAspectRatio);
video.width = tmpWidth;
video.height = tmpHeight;
video.x = Math.floor ((this.parent.width - 6 - video.width) / 2);
video.y = Math.floor ((this.parent.height - 29 - video.height) / 2);
}
public function onRestore(event:MDIWindowEvent):void {
video.x = 0;
video.y = 0;
video.width = _nSavedVideoWidth;
video.height = _nSavedVideoHeight;
adjustWindowSize();
}
override protected function resourcesChanged():void{
super.resourcesChanged();
this.title = ResourceUtil.getInstance().getString('bbb.publishVideo.title');
@ -182,7 +268,9 @@
<pubVid:states>
<!--http://stackoverflow.com/questions/369120/why-does-mxstates-have-trouble-being-resolved-to-a-component-implementation-->
<mx:State name="dispQuitControlBar">
<mx:State name="dispVideo">
</mx:State>
<!--mx:State name="dispQuitControlBar">
<mx:AddChild>
<mx:ControlBar id="quitOptionsBar">
<mx:Spacer width="50%"/>
@ -190,7 +278,7 @@
<mx:Spacer width="50%"/>
</mx:ControlBar>
</mx:AddChild>
</mx:State>
</mx:State-->
<mx:State name="dispVideoOptionsControlBar">
<mx:AddChild>
<mx:ControlBar id="videoOptionsBar">

View File

@ -40,6 +40,8 @@
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.videoconf.events.CloseAllWindowsEvent;
public var resolutions:Array = new Array("320x240", "640x480");
private var video:Video;
private var ns:NetStream;
private var videoHolder:UIComponent;
@ -47,12 +49,10 @@
private var videoHeight:Number;
private var videoWidth:Number;
private var _maxWidth:int = 800;
private var _maxHeight:int = 800;
private var _minWidth:int = 60;
private var _minHeight:int = 60;
private var _bResizePossible:Boolean = true;
private var _nAspectRatio:Number = 1;
private var _nSavedVideoWidth:Number;
private var _nSavedVideoHeight:Number;
private var _xPosition:int;
private var _yPosition:int;
@ -63,12 +63,19 @@
videoHolder = new UIComponent();
videoHolder.addChild(video);
this.addChild(videoHolder);
maximizeRestoreBtn.visible = false;
addEventListener(MDIWindowEvent.RESIZE_END, onResizeEndEvent);
maximizeRestoreBtn.visible = true;
addEventListener(MDIWindowEvent.RESIZE_END, onResizeEvent);
addEventListener(MDIWindowEvent.RESIZE, onResizeEvent);
addEventListener(MDIWindowEvent.MAXIMIZE, onMaximize);
addEventListener(MDIWindowEvent.RESTORE, onRestore);
addEventListener(MDIWindowEvent.CLOSE, onCloseEvent);
globalDispatcher = new Dispatcher();
this.minWidth = 166;
this.minHeight = 149;
maximizeRestoreBtn.visible = true;
this.resizable = true;
}
private function onCloseEvent(event:MDIWindowEvent = null):void {
@ -100,29 +107,28 @@
}
private function setVideoResolution(stream:String):void{
var resString:String = stream.substr(0, 7);
switch(resString){
case "320x240":
this.width = 320;
this.height = 240;
_nAspectRatio = (this.width/this.height)
break;
case "640x480":
this.width = 640;
this.height = 480;
for each (var resStr:String in resolutions){
LogUtil.debug("VideoWindow::setVideoResolution testing " + resStr);
if (resStr == stream.substr(0, resStr.length)) {
var res:Array = resStr.split( "x" );
this.width = Number(res[0]);
this.height = Number(res[1]);
LogUtil.debug("VideoWindow::setVideoResolution width=" + this.width + " height=" + this.height);
_nAspectRatio = (this.width/this.height);
break;
}
}
}
private function onAsyncError(e:AsyncErrorEvent):void{
LogUtil.debug("VIdeoWindow::asyncerror " + e.toString());
LogUtil.debug("VideoWindow::asyncerror " + e.toString());
}
public function onMetaData(info:Object):void{
LogUtil.debug("metadata: width=" + info.width + " height=" + info.height);
videoHolder.width = info.width;
videoHolder.height = info.height;
video.width = info.width;
video.height = info.height;
adjustWindowSize();
}
public function getPrefferedPosition():String{
@ -154,41 +160,75 @@
this.close();
}
public function onResizeEndEvent(event:MDIWindowEvent):void {
// make sure the height of the window is correct
if ( video.height + 29 > this.height) {
this.height = video.height + 29;
}
}
public function onResizeEvent(event:Event):void {
// test if we are already resizing
if (_bResizePossible) {
_bResizePossible = false;
private function adjustWindowSize():void{
videoHolder.width = video.width;
videoHolder.height = video.height;
this.width = video.width + 6;
this.height = video.height + 29;
}
public function onResizeEvent(event:MDIWindowEvent):void {
if (event.type == MDIWindowEvent.RESIZE) {
// test if we are already resizing
if (_bResizePossible) {
_bResizePossible = false;
resizeWindow();
_bResizePossible = true;
}
} else if (event.type == MDIWindowEvent.RESIZE_END) {
if (this.width > this.parent.width) {
this.width = this.parent.width;
this.height = Math.floor((this.width - 6) / _nAspectRatio) + 29;
}
if (this.height > this.parent.height) {
this.height = this.parent.height;
this.width = (this.height - 29) * _nAspectRatio + 6;
}
// make sure the size of the window is correct
resizeWindow();
_bResizePossible = true;
}
}
private function resizeWindow():void {
if (this.width > _maxWidth) {
this.width = _maxWidth;
}
if (this.height > _maxHeight) {
this.height = _maxHeight;
}
if (this.height < _minHeight) {
this.height = _minHeight;
}
if (this.width < _minWidth) {
this.width = _minWidth;
}
private function resizeWindow():void {
// recalc size of video based on the width and height of the window
video.width = this.width - 6;
// make sure the video has a correct aspectratio to avoid tall or flat faces
video.height = Math.floor (video.width / _nAspectRatio);
this.height = video.height + 29;
// make sure the video has a correct aspect ratio to avoid tall or flat faces
if (this.width == video.width + 6) {
video.height = this.height - 29;
video.width = video.height * _nAspectRatio;
} else {
video.width = this.width - 6;
video.height = Math.floor (video.width / _nAspectRatio);
}
adjustWindowSize();
}
public function onMaximize(event:MDIWindowEvent):void {
_nSavedVideoWidth = video.width;
_nSavedVideoHeight = video.height;
var tmpWidth:Number = this.parent.width - 6;
var tmpHeight:Number = this.parent.height - 29;
if (tmpWidth > tmpHeight * _nAspectRatio)
tmpWidth = tmpHeight * _nAspectRatio;
if (tmpHeight > Math.floor(tmpWidth / _nAspectRatio))
tmpHeight = Math.floor(tmpWidth / _nAspectRatio);
video.width = tmpWidth;
video.height = tmpHeight;
video.x = Math.floor ((this.parent.width - 6 - video.width) / 2);
video.y = Math.floor ((this.parent.height - 29 - video.height) / 2);
}
public function onRestore(event:MDIWindowEvent):void {
video.x = 0;
video.y = 0;
video.width = _nSavedVideoWidth;
video.height = _nSavedVideoHeight;
adjustWindowSize();
}
]]>