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()"
|
2010-05-20 23:53:00 +08:00
|
|
|
backgroundColor="white"
|
2010-05-01 03:38:55 +08:00
|
|
|
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-06-08 01:28:23 +08:00
|
|
|
import mx.controls.Image;
|
2010-06-04 05:59:21 +08:00
|
|
|
|
2010-07-17 00:28:54 +08:00
|
|
|
import org.bigbluebutton.modules.deskshare.events.CursorEvent;
|
|
|
|
import org.bigbluebutton.modules.deskshare.events.ViewStreamEvent;
|
2010-05-01 03:38:55 +08:00
|
|
|
import mx.controls.Button;
|
|
|
|
import mx.containers.Canvas;
|
2010-07-17 00:28:54 +08:00
|
|
|
import org.bigbluebutton.modules.deskshare.events.AppletStartedEvent;
|
2010-05-01 03:38:55 +08:00
|
|
|
import org.bigbluebutton.util.QueryStringParameters;
|
|
|
|
import mx.core.UIComponent;
|
2010-07-17 00:28:54 +08:00
|
|
|
import org.bigbluebutton.modules.deskshare.services.DeskshareService;
|
2010-05-01 03:38:55 +08:00
|
|
|
import org.bigbluebutton.common.Images;
|
|
|
|
|
|
|
|
private var videoHolder:UIComponent;
|
2010-06-04 05:59:21 +08:00
|
|
|
|
2010-05-28 23:07:55 +08:00
|
|
|
private var cursor:Shape = new Shape();;
|
2010-05-01 03:38:55 +08:00
|
|
|
|
|
|
|
private var images:Images = new Images();
|
|
|
|
[Bindable] public var bbbLogo:Class = images.bbb_logo;
|
2010-06-08 01:28:23 +08:00
|
|
|
|
2010-05-01 03:38:55 +08:00
|
|
|
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.graphics.lineStyle(6, 0xFF0000, 0.6);
|
2010-06-04 05:59:21 +08:00
|
|
|
cursor.graphics.drawCircle(0,0,3);
|
2010-05-12 02:11:51 +08:00
|
|
|
cursor.visible = false;
|
2010-06-04 05:59:21 +08:00
|
|
|
|
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-21 04:34:38 +08:00
|
|
|
startVideo(service.getConnection(), room, event.videoWidth, event.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-06-04 05:59:21 +08:00
|
|
|
videoHolder.addChild(cursorImg);
|
2010-05-21 01:50:57 +08:00
|
|
|
centerVideo();
|
2010-05-01 03:38:55 +08:00
|
|
|
ns.play(stream);
|
|
|
|
this.stream = stream;
|
2010-06-04 05:59:21 +08:00
|
|
|
vbox.addChild(videoHolder);
|
2010-05-01 03:38:55 +08:00
|
|
|
}
|
|
|
|
|
2010-05-21 01:50:57 +08:00
|
|
|
private function centerVideo():void {
|
|
|
|
videoHolder.x = vbox.width/2 - video.width/2;
|
|
|
|
videoHolder.y = vbox.height/2 - video.height/2;
|
|
|
|
}
|
|
|
|
|
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-06-02 03:55:08 +08:00
|
|
|
private function onUpdateCursorEvent(event:CursorEvent):void {
|
|
|
|
if (cursor == null) return;
|
2010-05-12 02:11:51 +08:00
|
|
|
cursor.x = ((event.x/video.videoWidth)) * videoHolder.width;
|
|
|
|
cursor.y = ((event.y/video.videoHeight)) * videoHolder.height;
|
2010-06-04 05:59:21 +08:00
|
|
|
// cursor.visible = true;
|
|
|
|
|
|
|
|
cursorImg.visible = true;
|
2010-06-11 22:27:55 +08:00
|
|
|
|
2010-06-11 01:27:29 +08:00
|
|
|
// DO NOT compute the x and y coordinate and assign directly to the cursorImg
|
|
|
|
// as it results in a flickering and jerky mouse pointer (ralam jun 10, 2010).
|
|
|
|
cursorImg.x = cursor.x;
|
|
|
|
cursorImg.y = cursor.y;
|
2010-06-08 01:28:23 +08:00
|
|
|
|
2010-05-12 02:11:51 +08:00
|
|
|
}
|
|
|
|
|
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
|
2010-05-20 23:53:00 +08:00
|
|
|
video.height = displayWidth * aspectRatio;
|
2010-05-20 02:27:06 +08:00
|
|
|
videoHolder.height = video.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function fitToHeightAndAdjustWidthToMaintainAspectRatio():void {
|
2010-05-20 23:53:00 +08:00
|
|
|
var aspectRatio:Number = video.width/video.height;
|
2010-05-20 02:27:06 +08:00
|
|
|
video.height = displayHeight;
|
|
|
|
videoHolder.height = video.height;
|
|
|
|
// Maintain aspect-ratio
|
2010-05-20 23:53:00 +08:00
|
|
|
video.width = aspectRatio * displayHeight;
|
2010-05-20 02:27:06 +08:00
|
|
|
videoHolder.width = video.width;
|
|
|
|
}
|
2010-05-01 03:38:55 +08:00
|
|
|
]]>
|
|
|
|
</mx:Script>
|
2010-07-17 00:28:54 +08:00
|
|
|
<mx:Image id="cursorImg" visible="false" source="@Embed('org/bigbluebutton/modules/deskshare/assets/images/cursor4.png')"/>
|
2010-06-04 05:59:21 +08:00
|
|
|
<mx:Canvas id="vbox" width="100%" height="100%"/>
|
2010-05-01 03:38:55 +08:00
|
|
|
</mx:Application>
|