home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
grafika-wolowiec.cba.pl
/
grafika-wolowiec.cba.pl.tar
/
grafika-wolowiec.cba.pl
/
res
/
imVideo.swf
/
scripts
/
imVideo_fla
/
MainTimeline.as
Wrap
Text File
|
2014-01-24
|
13KB
|
401 lines
package imVideo_fla
{
import adobe.utils.*;
import flash.accessibility.*;
import flash.desktop.*;
import flash.display.*;
import flash.errors.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.globalization.*;
import flash.media.*;
import flash.net.*;
import flash.net.drm.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.sensors.*;
import flash.system.*;
import flash.text.*;
import flash.text.engine.*;
import flash.text.ime.*;
import flash.ui.*;
import flash.utils.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip
{
public var file:String;
public var cWidth:Number;
public var cHeight:Number;
public var player:Video;
public var loader:Loader;
public var videoContainer:Object;
public var cwidth:Number;
public var cheight:Number;
public var connection:NetConnection;
public var stream:NetStream;
public var video:Video;
public var firstPlay:Boolean;
public var duration:uint;
public var origVolume:Number;
public var endTimer:Timer;
public var pausePlaceHolder:MovieClip;
public var playPlaceHolder:MovieClip;
public var isPlaying;
public var playerWidth;
public var playerHeight;
public var bg:MovieClip;
public var vobject:Object;
public var fullScreenRect:MovieClip;
public function MainTimeline()
{
super();
addFrameScript(0,this.frame1);
}
public function startLoading() : void
{
var vector3:Vector.<Number> = null;
this.bg = new MovieClip();
this.bg.graphics.beginFill(0);
this.bg.graphics.drawRect(0,0,stage.fullScreenWidth,stage.fullScreenHeight);
this.bg.graphics.endFill();
this.bg.visible = false;
addChild(this.bg);
try
{
this.connection = new NetConnection();
this.connection.connect(null);
this.stream = new NetStream(this.connection);
this.stream.client = this;
this.player = new Video();
addChild(this.player);
this.player.attachNetStream(this.stream);
this.stream.bufferTime = 1;
this.stream.receiveAudio(true);
this.stream.receiveVideo(true);
}
catch(e:*)
{
setTimeout(startLoading,100);
return;
}
finally
{
vector3 = new Vector.<Number>();
vector3[0] = 0;
vector3[1] = 100;
vector3[2] = 80;
vector3[3] = 50;
vector3[4] = 0;
vector3[5] = 0;
this.playPlaceHolder = new MovieClip();
this.playPlaceHolder.graphics.lineStyle(1,0);
this.playPlaceHolder.graphics.beginFill(16777215);
this.playPlaceHolder.alpha = 0.5;
this.playPlaceHolder.graphics.drawTriangles(vector3);
this.playPlaceHolder.graphics.endFill();
this.playPlaceHolder.x = (this.cWidth - 80) / 2;
this.playPlaceHolder.y = (this.cHeight - 100) / 2;
addChild(this.playPlaceHolder);
this.pausePlaceHolder = new MovieClip();
this.pausePlaceHolder.graphics.lineStyle(1,0);
this.pausePlaceHolder.graphics.beginFill(16777215);
this.pausePlaceHolder.alpha = 0.5;
this.pausePlaceHolder.graphics.drawRect(0,0,20,100);
this.pausePlaceHolder.graphics.drawRect(40,0,20,100);
this.pausePlaceHolder.graphics.endFill();
this.pausePlaceHolder.visible = false;
this.pausePlaceHolder.x = (this.cWidth - 80) / 2;
this.pausePlaceHolder.y = (this.cHeight - 100) / 2;
this.pausePlaceHolder.visible = false;
addChild(this.pausePlaceHolder);
}
stage.addEventListener(MouseEvent.CLICK,function(param1:Event):*
{
if(!isPlaying)
{
playVideo();
}
else
{
pauseVideo();
}
});
stage.addEventListener(MouseEvent.MOUSE_MOVE,function():*
{
if(isPlaying && !pausePlaceHolder.visible && stage.displayState != StageDisplayState.FULL_SCREEN)
{
pausePlaceHolder.visible = true;
}
});
stage.addEventListener(Event.MOUSE_LEAVE,function():*
{
pausePlaceHolder.visible = false;
});
stage.addEventListener(Event.FULLSCREEN,function(param1:FullScreenEvent):*
{
if(stage.displayState == StageDisplayState.FULL_SCREEN)
{
playerWidth = cWidth;
playerHeight = cHeight;
cWidth = stage.fullScreenWidth;
cHeight = stage.fullScreenHeight;
bg.visible = true;
playPlaceHolder.visible = false;
pausePlaceHolder.visible = false;
if(fullScreenRect != null)
{
fullScreenRect.visible = false;
}
}
else
{
cWidth = playerWidth;
cHeight = playerHeight;
bg.visible = false;
}
onMetaData(vobject);
});
}
public function playVideo() : void
{
if(this.endTimer != null)
{
this.endTimer.start();
}
if(this.firstPlay)
{
this.firstPlay = false;
this.stream.play(this.file);
}
else
{
this.stream.resume();
}
this.isPlaying = true;
this.playPlaceHolder.visible = false;
}
public function onMetaData(param1:Object) : void
{
if(param1 != null)
{
if(this.vobject == null)
{
this.vobject = param1;
}
this.duration = param1.duration;
this.player.height = this.cWidth / param1.width * param1.height;
this.player.width = this.cWidth;
if(this.player.height > this.cHeight)
{
this.player.width = this.cHeight / param1.height * param1.width;
this.player.height = this.cHeight;
}
this.player.x = (this.cWidth - this.player.width) / 2;
this.player.y = (this.cHeight - this.player.height) / 2;
}
this.playPlaceHolder.x = (this.cWidth - 80) / 2;
this.playPlaceHolder.y = (this.cHeight - 100) / 2;
this.pausePlaceHolder.x = (this.cWidth - 80) / 2;
this.pausePlaceHolder.y = (this.cHeight - 100) / 2;
}
public function stopVideo() : void
{
this.pauseVideo();
}
public function pauseVideo() : void
{
this.pausePlaceHolder.visible = false;
this.playPlaceHolder.visible = true;
this.stream.pause();
this.isPlaying = false;
}
public function seekTo(param1:Number) : void
{
this.stream.seek(param1);
}
public function setVol(param1:Number) : void
{
this.origVolume = param1;
this.stream.soundTransform = new SoundTransform(param1);
}
function frame1() : *
{
this.file = "";
this.cWidth = 400;
this.cHeight = 400;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
if(this.root.loaderInfo.parameters.cWidth != null)
{
this.cWidth = this.root.loaderInfo.parameters.cWidth;
}
else
{
stage.scaleMode = StageScaleMode.SHOW_ALL;
stage.align = StageAlign.TOP;
}
if(this.root.loaderInfo.parameters.cHeight != null)
{
this.cHeight = this.root.loaderInfo.parameters.cHeight;
}
else
{
stage.scaleMode = StageScaleMode.SHOW_ALL;
stage.align = StageAlign.TOP;
}
if(this.root.loaderInfo.parameters.fileName != null)
{
this.file = this.root.loaderInfo.parameters.fileName;
}
this.file = this.file.replace("{amp}","&");
if(this.file.length == 0 || this.file.indexOf(".swf") != -1 || this.file.indexOf(".js") != -1)
{
return;
}
this.loader = new Loader();
this.firstPlay = true;
this.duration = 0;
this.origVolume = 0.75;
this.isPlaying = false;
this.playerWidth = null;
this.playerHeight = null;
this.bg = null;
this.vobject = null;
this.fullScreenRect = null;
if(ExternalInterface.available)
{
try
{
ExternalInterface.addCallback("FlashPlay",function(param1:String = ""):*
{
playVideo();
});
ExternalInterface.addCallback("FlashPause",function(param1:String = ""):*
{
pauseVideo();
});
ExternalInterface.addCallback("FlashStop",function(param1:String = ""):*
{
stopVideo();
});
ExternalInterface.addCallback("FlashLength",function(param1:String = ""):*
{
return duration;
});
ExternalInterface.addCallback("FlashCurrentPosition",function(param1:String = ""):*
{
if(stream == null)
{
return 0;
}
return stream.time;
});
ExternalInterface.addCallback("FlashBuffer",function(param1:String = ""):*
{
if(stream == null)
{
return 0;
}
return stream.bytesLoaded / stream.bytesTotal;
});
ExternalInterface.addCallback("FlashScroll",function(param1:Number = 0):*
{
seekTo(param1);
});
ExternalInterface.addCallback("FlashSetVolume",function(param1:Number = 0):*
{
setVol(param1);
});
ExternalInterface.addCallback("FlashGetVolume",function(param1:String = ""):*
{
return origVolume;
});
ExternalInterface.addCallback("FlashIsPlaying",function(param1:String = ""):*
{
return isPlaying;
});
ExternalInterface.addCallback("FlashFullScreen",function(param1:String = ""):*
{
var value:String = param1;
fullScreenRect = new MovieClip();
fullScreenRect.graphics.beginFill(10066329);
fullScreenRect.graphics.drawRect(0,0,cWidth,30);
fullScreenRect.graphics.endFill();
fullScreenRect.x = 0;
fullScreenRect.y = 0;
fullScreenRect.width = cWidth;
fullScreenRect.height = 30;
addChild(fullScreenRect);
var txt:TextField = new TextField();
txt.width = cWidth - 20;
txt.height = 27;
txt.x = 10;
txt.y = 3;
txt.text = "Click here to go Full Screen";
txt.setTextFormat(new TextFormat("Arial",16,16777215,false,false,false,null,null,"center"));
fullScreenRect.addChild(txt);
fullScreenRect.buttonMode = true;
fullScreenRect.useHandCursor = true;
fullScreenRect.mouseChildren = false;
fullScreenRect.addEventListener(MouseEvent.CLICK,function(param1:Event):*
{
param1.stopImmediatePropagation();
removeChild(fullScreenRect);
fullScreenRect = null;
txt = null;
stage.displayState = StageDisplayState.FULL_SCREEN;
});
setTimeout(function():*
{
removeChild(fullScreenRect);
fullScreenRect = null;
txt = null;
},5000);
});
}
catch(e:*)
{
}
}
this.startLoading();
}
}
}