Hi.
I'm creating a video (FLV) player that plays multiple FLVs. I've come across a problem: when it switches to another video of different aspect ratios, it messes up, usually all video take on the same aspect ratio of the first and when the stage is resized, it messes up completely.
The first video is 590x300, the second and third are 720x576..
I'm also going to give you the code (AS3) so you can see if and where I made a mistake or error.
This function is called at the start to set up the video:
Code:
private function setUpVideo():void {
// this create a new video and sets up the necessary connections and adds the necessary listeners
vid = new Video(_xml.video[onVideo].@width, _xml.video[onVideo].@height);
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
vid.attachNetStream(ns);
ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
ns.client = this;
ns.soundTransform = soundTrans;
_base.holder.addEventListener(Event.ENTER_FRAME, videoStatus);
_base.holder.addChild(vid);
}
Once the video finishes playing, this function is called:
Code:
private function startVideo(vidPath:String):void {
ns.play(vidPath);
vid.smoothing = true;
sizeVideo();
if (firstTime) {
firstTime = false;
if (_xml.@video_start_paused == "yes") {
ns.pause();
} else {
isPlaying = true;
_base.controlsclip.playpausebutn.symbolclip.gotoAndStop(2);
}
ns.seek(0);
}
}
And here is the sizeVideo function that is called in the previous function; this is also called on stageResize:
Code:
private function sizeVideo():void {
vid.scaleX = vid.scaleY = 1;
vid.x = vid.y = 0;
xsf = uint(_xml.video[onVideo].@width) / _base.stage.stageWidth;
ysf = uint(_xml.video[onVideo].@height) / _base.stage.stageHeight;
if (xsf < ysf) {
vid.height = _base.stage.stageHeight;
vid.scaleX = vid.scaleY;
vid.x = Math.round((_base.stage.stageWidth / 2) - (vid.width / 2));
} else {
vid.width = _base.stage.stageWidth;
vid.scaleY = vid.scaleX;
vid.y = Math.round((_base.stage.stageHeight / 2) - (vid.height / 2));
}
}
Thanks for reading! Please help.