2010-05-01 03:38:55 +08:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
|
|
|
xmlns:mate="http://mate.asfusion.com/"
|
|
|
|
creationComplete="onCreationComplete()"
|
|
|
|
width="100%" height="100%"
|
|
|
|
layout="absolute">
|
|
|
|
|
|
|
|
<mate:Listener type="{AppletStartedEvent.APPLET_STARTED}" method="onAppletStart" />
|
2010-05-06 22:26:06 +08:00
|
|
|
<mate:Listener type="{ViewStreamEvent.STOP}" method="onAppletStop" />
|
2010-05-06 23:39:20 +08:00
|
|
|
<mate:Listener type="{ViewStreamEvent.START}" method="onViewStreamStart"/>
|
2010-05-12 02:11:51 +08:00
|
|
|
<mate:Listener type="{CursorEvent.UPDATE_CURSOR_LOC_EVENT}" method="onUpdateCursorEvent" />
|
2010-05-01 03:38:55 +08:00
|
|
|
<mx:Script>
|
|
|
|
<![CDATA[
|
2010-05-20 02:27:06 +08:00
|
|
|
import mx.controls.Alert;
|
2010-05-12 02:11:51 +08:00
|
|
|
import org.bigbluebutton.modules.deskShare.events.CursorEvent;
|
2010-05-01 03:38:55 +08:00
|
|
|
import org.bigbluebutton.modules.deskShare.events.ViewStreamEvent;
|
|
|
|
import mx.controls.Button;
|
|
|
|
import mx.containers.Canvas;
|
|
|
|
import org.bigbluebutton.modules.deskShare.events.AppletStartedEvent;
|
|
|
|
import org.bigbluebutton.util.QueryStringParameters;
|
|
|
|
import mx.core.UIComponent;
|
|
|
|
import org.bigbluebutton.modules.deskShare.services.DeskshareService;
|
|
|
|
import org.bigbluebutton.common.Images;
|
|
|
|
|
|
|
|
private var videoHolder:UIComponent;
|
2010-05-12 02:11:51 +08:00
|
|
|
|
|
|
|
private var cursor:Shape;
|
2010-05-01 03:38:55 +08:00
|
|
|
|
|
|
|
private var images:Images = new Images();
|
|
|
|
[Bindable] public var bbbLogo:Class = images.bbb_logo;
|
|
|
|
|
|
|
|
private var video:Video;
|
|
|
|
private var ns:NetStream;
|
|
|
|
private var stream:String;
|
|
|
|
private var logoutURL:String;
|
|
|
|
private var host:String;
|
|
|
|
private var room:String;
|
2010-05-20 02:27:06 +08:00
|
|
|
private var displayWidth:Number;
|
|
|
|
private var displayHeight:Number;
|
2010-05-01 03:38:55 +08:00
|
|
|
|
|
|
|
private var service:DeskshareService = new DeskshareService();
|
|
|
|
|
|
|
|
private function onCreationComplete():void {
|
|
|
|
var p:QueryStringParameters = new QueryStringParameters();
|
|
|
|
p.collectParameters();
|
|
|
|
logoutURL = p.getParameter("LOGOUTURL");
|
|
|
|
host = p.getParameter("HOST");
|
|
|
|
room = p.getParameter("ROOM");
|
|
|
|
service.connect(host+"/"+room);
|
2010-05-12 02:11:51 +08:00
|
|
|
|
|
|
|
cursor = new Shape();
|
|
|
|
cursor.graphics.lineStyle(6, 0xFF0000, 0.6);
|
|
|
|
cursor.graphics.drawCircle(0,0,3);
|
|
|
|
|
|
|
|
cursor.visible = false;
|
2010-05-20 02:27:06 +08:00
|
|
|
displayWidth = this.parent.width;
|
|
|
|
displayHeight = this.parent.height;
|
2010-05-01 03:38:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private function onAppletStart(event:AppletStartedEvent):void{
|
2010-05-20 02:27:06 +08:00
|
|
|
// startVideo(service.getConnection(), room, videoWidth, videoHeight);
|
2010-05-01 03:38:55 +08:00
|
|
|
}
|
2010-05-06 23:39:20 +08:00
|
|
|
|
|
|
|
private function onViewStreamStart(event:ViewStreamEvent):void {
|
2010-05-20 02:27:06 +08:00
|
|
|
startVideo(service.getConnection(), room, event.videoWidth, event.videoHeight);
|
2010-05-06 23:39:20 +08:00
|
|
|
}
|
2010-05-01 03:38:55 +08:00
|
|
|
|
|
|
|
private function onAppletStop(event:ViewStreamEvent):void {
|
|
|
|
var url:URLRequest = new URLRequest(logoutURL);
|
|
|
|
navigateToURL(url, '_self');
|
|
|
|
}
|
2010-05-20 02:27:06 +08:00
|
|
|
|
|
|
|
private function startVideo(connection:NetConnection, stream:String, videoWidth:Number, videoHeight:Number):void{
|
2010-05-01 03:38:55 +08:00
|
|
|
ns = new NetStream(connection);
|
|
|
|
ns.addEventListener( NetStatusEvent.NET_STATUS, onNetStatus );
|
|
|
|
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
|
|
|
|
ns.client = this;
|
|
|
|
ns.bufferTime = 0;
|
|
|
|
ns.receiveVideo(true);
|
|
|
|
ns.receiveAudio(false);
|
2010-05-20 02:27:06 +08:00
|
|
|
video = new Video(videoWidth, videoHeight);
|
2010-05-01 03:38:55 +08:00
|
|
|
video.attachNetStream(ns);
|
|
|
|
|
|
|
|
videoHolder = new UIComponent();
|
2010-05-20 02:27:06 +08:00
|
|
|
calculateDisplayDimensions(video, videoHolder);
|
2010-05-12 02:11:51 +08:00
|
|
|
videoHolder.addChild(video);
|
|
|
|
videoHolder.addChild(cursor);
|
2010-05-01 03:38:55 +08:00
|
|
|
ns.play(stream);
|
|
|
|
this.stream = stream;
|
|
|
|
vbox.addChild(videoHolder);
|
|
|
|
}
|
|
|
|
|
2010-05-20 02:27:06 +08:00
|
|
|
private function calculateDisplayDimensions(video:Video, videoHolder:UIComponent):void {
|
|
|
|
if (videoIsSmallerThanDisplay(video, videoHolder)) {
|
|
|
|
videoHolder.width = video.width;
|
|
|
|
videoHolder.height = video.height;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (displayWidth < displayHeight) {
|
|
|
|
fitToWidthAndAdjustHeightToMaintainAspectRatio();
|
|
|
|
} else {
|
|
|
|
fitToHeightAndAdjustWidthToMaintainAspectRatio();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-12 02:11:51 +08:00
|
|
|
private function onUpdateCursorEvent(event:CursorEvent):void {
|
|
|
|
cursor.x = ((event.x/video.videoWidth)) * videoHolder.width;
|
|
|
|
cursor.y = ((event.y/video.videoHeight)) * videoHolder.height;
|
|
|
|
cursor.visible = true;
|
|
|
|
}
|
|
|
|
|
2010-05-01 03:38:55 +08:00
|
|
|
public function stopViewing():void {
|
|
|
|
ns.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function onAsyncError(e:AsyncErrorEvent):void{
|
|
|
|
trace("VIdeoWindow::asyncerror " + e.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
private function onNetStatus(e:NetStatusEvent):void{
|
|
|
|
switch(e.info.code){
|
|
|
|
case "NetStream.Play.Start":
|
|
|
|
trace("NetStream.Publish.Start for broadcast stream " + stream);
|
|
|
|
trace("Dispatching start viewing event");
|
|
|
|
service.sendStartedViewingNotification();
|
|
|
|
break;
|
|
|
|
case "NetStream.Play.UnpublishNotify":
|
|
|
|
trace("NetStream.Play.UnpublishNotify for broadcast stream " + stream);
|
|
|
|
stopViewing();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-20 02:27:06 +08:00
|
|
|
private function videoIsSmallerThanDisplay(video:Video, videoHolder:UIComponent):Boolean {
|
|
|
|
return (video.height < displayHeight) && (video.width < displayWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function fitToWidthAndAdjustHeightToMaintainAspectRatio():void {
|
|
|
|
var aspectRatio:Number = video.height/video.width;
|
|
|
|
video.width = displayWidth;
|
|
|
|
videoHolder.width = video.width;
|
|
|
|
// Maintain aspect-ratio
|
|
|
|
video.height = displayHeight * aspectRatio;
|
|
|
|
videoHolder.height = video.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function fitToHeightAndAdjustWidthToMaintainAspectRatio():void {
|
|
|
|
var aspectRatio:Number = video.height/video.width;
|
|
|
|
video.height = displayHeight;
|
|
|
|
videoHolder.height = video.height;
|
|
|
|
// Maintain aspect-ratio
|
|
|
|
video.width = (aspectRatio * displayWidth);
|
|
|
|
videoHolder.width = video.width;
|
|
|
|
}
|
2010-05-01 03:38:55 +08:00
|
|
|
]]>
|
|
|
|
</mx:Script>
|
|
|
|
<mx:Canvas id="vbox" width="100%" height="100%"/>
|
|
|
|
</mx:Application>
|