Flex 4: The basic webcam group shows and hides based on content

This commit is contained in:
Chad Pilkey 2016-05-21 14:12:36 -04:00
parent f83108ed34
commit 50cfd19cbb
4 changed files with 34 additions and 8 deletions

View File

@ -36,7 +36,6 @@ package org.bigbluebutton.web.main.views {
addElement(_presentationView);
_videoContainer = new WebcamGroup();
_videoContainer.height = 200;
_videoContainer.percentWidth = 100;
addElement(_videoContainer);

View File

@ -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);
}
/**

View File

@ -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);

View File

@ -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();