?
Solved

How to center align an flv video in FLVPlayback

Posted on 2009-02-17
7
Medium Priority
?
2,312 Views
Last Modified: 2013-11-11
Hi,
I have an FLVPlayback on stage defined as W:510.0 and H:286.9 (16:9 aspect ratio) and a video i am loading into the swf with dimensions W:368 x H:208 (also 19:9). When the video loads into the defined FLVPlayback video it loads with its original dimensions to the far left with a massive black area to the right of the video.My questions are:
1- Is it not possible to center align the video within the FLVplayback?
2- Since they are both 16:9 cant i just make the video take up the full FLVPlayback area defined?
Code is AS2.
Thanks.
0
Comment
Question by:guswebb
  • 4
  • 2
7 Comments
 
LVL 8

Accepted Solution

by:
brittonv earned 1500 total points
ID: 23659022
3 easy steps.

1. Make a black square movieclip.  
2. Set it to the size you want.  
3. Position the resized FLV video in the center of it.
0
 
LVL 8

Assisted Solution

by:brittonv
brittonv earned 1500 total points
ID: 23659045
Here is some code I found that my illuminate things for you.

           attachMovie("FLVPlayback", "my_FLVPlybk", 10, {width:320, height:240, x:90, y:100});
            //center the FLVPlayback component when FLV is ready to play
            var listenerObject:Object = new Object();
            listenerObject.resize = function(eventObject:Object):Void {
                //center video in playback area
                newx = (460 - my_FLVPlybk.preferredWidth)/2;
                newy = (470 - my_FLVPlybk.preferredHeight)/2;
                my_FLVPlybk._x = newx;
                my_FLVPlybk._y = newy;
            };
            my_FLVPlybk.addEventListener("resize", listenerObject);    
            listenerObject.ready = function(eventObject:Object):Void {
                my_FLVPlybk.setSize(250, 350);
0
 
LVL 9

Author Comment

by:guswebb
ID: 23659065
I am going to be dynamically passing in different sized videos so that approach will not work, the case about the video size i mentioned was only an example. Im might want to pass in a video of aspect ratio 3:4 in which case your idea will not make it centered, i am looking for some actionscript code. (for both of my questons)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Author Comment

by:guswebb
ID: 23659094
Your code is moving the whole FLVPlayback, i dont want to do that, surely there must be a way by something like this:
FLVideo.scaleMode = VideoScaleMode.NO_SCALE;
FLVVideo.align = VideoAlign.CENTER;
// these dont work however
0
 
LVL 9

Author Comment

by:guswebb
ID: 23662042
Ok after alot of looking around this is what ive come up with:

1- There is no simple centering of video within flvplayback so ill have to use brittonv's reposition solution.

2- Since they are both 16:9 cant i just make the video take up the full FLVPlayback area defined?
After i did my own testing: Yes by setting the autosize of the flvplayback to false and setting maintainaspect ratio to true + it might be best to make sure all the videos are 16:9 aswell.



0
 
LVL 9

Author Closing Comment

by:guswebb
ID: 31547751
This reassures me that the only probable way is to reposition the FLVplayback which answers part 1 of my question.
0
 

Expert Comment

by:desperation
ID: 25685021
I was having a similar issue I have an application that has videos encoded at 400 x 300 and 480 x 270.

Flash CS3 encoder embeds all kinds of goodies into the metadata of the video; older FLV files will have the height and width only.

Here's what I did.
Followed adobe's metadata example http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00003022.html 

And added a switch statement to change the x position of myFLV based on what the metadata.

Hope that helps - works like a charm for me.

import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.metadataReceived = function(eventObject:Object):Void {
        trace("canSeekToEnd is " + myFLV.metadata.canSeekToEnd);
        trace("Number of cue points is " + myFLV.metadata.cuePoints.length);
        trace("Frame rate is " + myFLV.metadata.framerate);
        trace("Height is " + myFLV.metadata.height);
        trace("Width is " + myFLV.metadata.width);
        trace("Duration is " + myFLV.metadata.duration + " seconds");
        var vidWidth:Number = myFLV.metadata.width;
		switch(vidWidth) {
			case 480:
                        //stage width is 500 myFLV
			myFLV._x = 10;
			break;
			
			case 400:
			myFLV._x = 50;
			break;
		}
 
};
myFLV.addEventListener("metadataReceived", listenerObject);
myFLV.contentPath = "http://www.helpexamples.com/flash/video/cuepoints.flv";

Open in new window

0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question