From 50cfd19cbb1057177c9f26d0d86a4a66742b4eb2 Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Sat, 21 May 2016 14:12:36 -0400 Subject: [PATCH] Flex 4: The basic webcam group shows and hides based on content --- .../bigbluebutton/web/main/views/MainPanel.as | 1 - .../bigbluebutton/web/video/VideoConfig.as | 3 --- .../web/video/views/WebcamGroup.as | 17 +++++++++++++++ .../web/video/views/WebcamGroupMediator.as | 21 +++++++++++++++---- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/clients/flash/web-client/src/org/bigbluebutton/web/main/views/MainPanel.as b/clients/flash/web-client/src/org/bigbluebutton/web/main/views/MainPanel.as index 74bb42bd07..1de5b86cbd 100644 --- a/clients/flash/web-client/src/org/bigbluebutton/web/main/views/MainPanel.as +++ b/clients/flash/web-client/src/org/bigbluebutton/web/main/views/MainPanel.as @@ -36,7 +36,6 @@ package org.bigbluebutton.web.main.views { addElement(_presentationView); _videoContainer = new WebcamGroup(); - _videoContainer.height = 200; _videoContainer.percentWidth = 100; addElement(_videoContainer); diff --git a/clients/flash/web-client/src/org/bigbluebutton/web/video/VideoConfig.as b/clients/flash/web-client/src/org/bigbluebutton/web/video/VideoConfig.as index 90c6afb968..0db2a0114f 100644 --- a/clients/flash/web-client/src/org/bigbluebutton/web/video/VideoConfig.as +++ b/clients/flash/web-client/src/org/bigbluebutton/web/video/VideoConfig.as @@ -1,6 +1,4 @@ package org.bigbluebutton.web.video { - import org.bigbluebutton.web.video.views.VideoWindow; - import org.bigbluebutton.web.video.views.VideoWindowMediator; import org.bigbluebutton.web.video.views.WebcamGroup; import org.bigbluebutton.web.video.views.WebcamGroupMediator; @@ -39,7 +37,6 @@ package org.bigbluebutton.web.video { */ private function mediators():void { mediatorMap.map(WebcamGroup).toMediator(WebcamGroupMediator); - //mediatorMap.map(VideoWindow).toMediator(VideoWindowMediator); } /** diff --git a/clients/flash/web-client/src/org/bigbluebutton/web/video/views/WebcamGroup.as b/clients/flash/web-client/src/org/bigbluebutton/web/video/views/WebcamGroup.as index 72aec6b96e..159e9b3811 100644 --- a/clients/flash/web-client/src/org/bigbluebutton/web/video/views/WebcamGroup.as +++ b/clients/flash/web-client/src/org/bigbluebutton/web/video/views/WebcamGroup.as @@ -8,6 +8,8 @@ package org.bigbluebutton.web.video.views { private var _minContentAspectRatio:Number = 4 / 3; + private var _numVideos:Number = 0;; + public function WebcamGroup() { super(); @@ -17,17 +19,32 @@ package org.bigbluebutton.web.video.views { } public function addVideo(v:WebcamView):void { + var count:uint = this.numElements; addElement(v); + if (count < this.numElements) _numVideos++; + + validateHeight(); + _minContentAspectRatio = minContentAspectRatio(); invalidateDisplayList(); } public function removeVideo(v:WebcamView):void { + var count:uint = this.numElements; removeElement(v); + if (count > this.numElements) _numVideos--; + + validateHeight(); + _minContentAspectRatio = minContentAspectRatio(); invalidateDisplayList(); } + private function validateHeight():void { + if (_numVideos > 0) height = 200; + else height = 0; + } + override protected function updateDisplayList(w:Number, h:Number):void { super.updateDisplayList(w, h); diff --git a/clients/flash/web-client/src/org/bigbluebutton/web/video/views/WebcamGroupMediator.as b/clients/flash/web-client/src/org/bigbluebutton/web/video/views/WebcamGroupMediator.as index 84dcce68bd..1a56edd64d 100644 --- a/clients/flash/web-client/src/org/bigbluebutton/web/video/views/WebcamGroupMediator.as +++ b/clients/flash/web-client/src/org/bigbluebutton/web/video/views/WebcamGroupMediator.as @@ -83,15 +83,14 @@ package org.bigbluebutton.web.video.views { private function userChangeHandler(user:User, type:int):void { if (type == UserList.HAS_STREAM) { + var streamNames:Array = []; if (user.streamName.length > 0) { - var streamNames:Array = user.streamName.split("|"); + streamNames = user.streamName.split("|"); for each (var streamName:String in streamNames) { startStream(user, streamName); } - // removeUnusedStreams(user.userID, streamNames); - } else { - // removeWebcam(user); } + removeUnusedStreams(user, streamNames); // view.invalidateDisplayList(); } else { // updateUser(user); @@ -106,6 +105,20 @@ package org.bigbluebutton.web.video.views { */ } + private function removeUnusedStreams(user:User, streamNames:Array):void { + var openStreams:Array = findVideosByUserId(user.userId); + for each (var openStream:WebcamView in openStreams) { + var active:Boolean = false; + for each (var activeStream:String in streamNames) { + if (openStream.streamName == activeStream) { + active = true; + break; + } + } + if (!active) stopStream(user, openStream.streamName); + } + } + private function startStream(user:User, streamName:String):void { if (findVideoByStreamName(streamName) == null) { var newWebcam:WebcamView = new WebcamView();