How to Load External Flash Video (FLV) Files (AS3)
This article can be considered a sequel to “How to Load External Flash Video (FLV) Files (AS2).” The code suggested here is nothing more than the ActionScript 3.0 way to accomplish the same goal achieved earlier; namely, to load an external Flash video (FLV) file at runtime — without using the FLVPlayback component. To be sure, there’s nothing wrong with FLVPlayback. Its skins are customizable (all the more so in Flash CS3, which is the first version of Flash to support AS3) and it provides plenty of built-in widgets, such as play/pause, a volume slider, mute button, and the like. But to get those features, even if you choose a non-skinned component, you pay a 49KB price in an ActionScript 3.0 document. If you go without the component, it costs you less than 1KB. That means site visitors can spend their bandwidth on your video content itself, rather than the video player.
An answer, short and sweet
As described in the AS2 version of this article, you’re going to use an instance each of the NetConnection and NetStream classes in addition to a Video object. In ActionScript 3.0 — this is really neat — you can even create your Video instance via ActionScript. This is new. If you like, though, you can also still use the Library panel to create a video asset beforehand and drag it to the Stage. We’ll look at both approaches. First, the completely programmatic way:
var vid:Video = new Video(320, 240);
addChild(vid);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
vid.attachNetStream(ns);
var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;
ns.play("externalVideo.flv");
How it works
An arbitrarily named variable, vid, is declared and set to an instance of the Video class. To specify the size of this video, two parameters are passed into the constructor: a width and height of 320 and 240 pixels. As it turns out, this is the default, so you can leave those numbers out completely and your video will show as 320×240. If you want something bigger or smaller, or if your video’s dimensions are some other aspect ratio, specify the relevant numbers. The line immediately following, addChild(vid), invokes the DisplayObjectContainer.addChild() method on the timeline in which this code appears.
Why the timeline? Because the method stands alone, doesn’t have an object reference prefixed to it. (In contrast, other methods in the above snippet are preceded by object references.) What’s a DisplayObjectContainer? Well, it’s just another class, like the others we’re using here. DisplayObjectContainer is inherited by a number of everyday classes, such as MovieClip.
The timeline in which this code appears (i.e., the main timeline) actually is a MovieClip instance, which means it has access to the addChild() method thanks to the fact that DisplayObjectContainer is a grandparent in its family tree. By “adding the child” vid, you’re simply making the Video object visible. You’re adding it to the display list of the main timeline, which means it’ll show up visually (even though it exists before then and would even if you failed to add it to the list — in which case it just wouldn’t show).
So now we have a Video object to display the video. Now we need to hook it up. Another arbitrarily named variable, nc, is declared and set to an instance of the NetConnection class, then the NetConnection.connect() method is called on it and passed a null parameter. Why null? All that means is that we’re requesting a progressive download FLV file; that is, one that isn’t streamed via Flash Media Server.
With this connection established, a third arbitrarily named variable, ns, is declared and set to an instance of the NetStream class. This instance is associated with the net connection, and the Video.attachNetStream() method is invoked on vid to associate it with the net stream. This may be a bit tedious, but it’s not too bad, and certainly pretty straightforward.
The next three lines merit a bit of explanation. Here they are again:
var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;
This is one of the very few exceptions to how event handing is done in ActionScript 3.0. Normally, the task is done as described in this excellent article by Trevor McCauley, “Introduction to event handling in ActionScript 3.0.” Here, the NetStream.onMetaData event is taken care of by a sort of liaison — a generic Object instance — the way it’s often done in AS2. Why are we even handling onMetaData? Strictly speaking, you don’t have to. If your FLV doesn’t have metadata embedded in it, the onMetaData event won’t be dispatched when the video starts playing. Most FLV encoders, however (including the native Flash Import Video Wizard), do embed metadata, and if you don’t handle the dispatched event, you’ll see an error message in the Output panel. The above three lines simply create a dummy stand-in function (that doesn’t do anything) and associate it with an onMetaData property of the Object instance, arbitrarily named listener. This object is then connected with the NetStream instance by way of its client property.
Finally, NetStream.play() is invoked on ns and told which FLV to play.
What if I prefer a made-by-hand Video object?
If you remember the AS2 version of this article and prefer your older workflow, drop the first two lines of the above code sample. Instead, right-click / Command-click in an open space in your Library panel, choose New Video… from the context menu, hit OK to accept the default values — this gives you an ActionScript-controllable Video object with an asset name of Video 1 — then drag that asset to the Stage. Size it to the dimensions of your video content, then use the Property inspector to give the object an instance name, such as videoPlayer. That instance name will be your key to associating this Video object with the NetStream instance:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
videoPlayer.attachNetStream(ns);
var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;
ns.play("externalVideo.flv");
And there you have it. See how most of that code overlaps?
November 15th, 2007 at 10:07 am
The rest of the other articles on your site to build your own video component are AS2. With this new AS3 article, can I use the same code from the old articles with AS3 or is all the code totally different now?
November 15th, 2007 at 10:10 am
Chad,
The principles, in many cases, are the same. Reading the older AS2 articles may help you conceptually in AS3, but the syntax is different. I plan to write “sequels” to the most popular of my AS2 articles.
November 15th, 2007 at 10:33 am
Thanks for your quick response.
Is there some kind of book or reference that I could get right now that would help me convert all of your AS2 code to AS3? My boss wants me to make a new video player for our site in AS3 for some reason (he loves new technology) and I don’t know enough about AS3 yet to be confident in converting your code and know where I am screwing up when I get errors.
November 15th, 2007 at 10:56 am
Chad,
At the moment, I’m tech editing a new title for friends of ED, Foundation Flash CS3 Video (title subject to change), by Tom Green and Adam Thomas. Obviously, as that’s in the works, it won’t be in stores quick enough to help you out. Tom and I wrote Foundation Flash CS3 for Designers (friends of ED) and that touches on video, but isn’t a video-specific book. You might swing by a book store during lunch, though, and flip through … we do cover how to use built-in video controls to customize things a bit. You may also want to flip through Robert Reinhardt’s Adobe Flash CS3 Professional Video Studio Techniques. Robert’s a friend of mine, and I trust his work, hands down, as top notch. Still, I don’t know the full scope of what he covered in that one.
While I love AS3, I should let you know that by using it, your boss is requiring users to have Flash Player 9 installed. Unless you’re planning to use the fullscreen feature of Flash Player 9, you could do this in AS2 for Flash Player 8 (or 7 or 9!) just fine.
Migrating from AS2 to AS3 ranges anywhere from easy to mind-numbingly crazy, depending on any number of random factors. (I know, encouraging, right?!) A good rule of thumb, though, in all cases, is to break down your main goal — a custom video player — into smaller and smaller subgoals, then conquer each small step one at a time.
These Adobe articles might give you a leg up:
ActionScript 3.0 Overview
Tips for learning ActionScript 3.0
November 15th, 2007 at 11:05 am
Thanks again David.
I think I am going to do one of two things.
1.) Talk to him about it and try to convince him to go with AS2 using the reasons you listed
2.) Just code it in AS2 and tell him it’s AS3 and he’ll never even know the difference.
I think I’m leaning more toward 2. Developers can be very sneaky!
November 15th, 2007 at 11:06 am
Chad,
Mum’s the word!
November 16th, 2007 at 10:45 pm
we just did a site in AS3… and I had to jump into it…
just do a project with it.. bang your head against the wall, and then you’ll be fine… I’m still not confident with it… but it’s not as much of a hairy beast as it’s made out to be.. with some stuff that is harder, there are quite a few things that are easier.. (ie: Timer, not having to use Delegate)..
November 24th, 2007 at 4:36 pm
Hi David,
Thank you for hosting this useful blog.
I have large flv’s (approx twenty flv’s about 100 megs each) on a DVD. I used your code to load them. They play when loaded but the playback is choppy.
I added the line ns.bufferTime = 20 thinking I would preload 20 seconds of the video before it started to play. After increasing the bufferTime, it appears that the video is paused until enough of the video is “preloaded” but the video is still choppy when the play starts. The DVD drive is going at the same time the video is playing so either the video is playing from the start of the file on the DVD or the player is preloading more data from the DVD to keep the cache up…not sure which.
What I think is happening is that the flash player is “seeing” that all of the data is there (on the DVD) for it to start playing, but it is not playing it from cached memory but from the DVD itself.
Experimenting with larger numbers for the bufferTime number did cause the video to start later so I am thinking that the video is being cached somewhere, however the playback still seems to be coming from the DVD resulting in a choppy playback.
Implementing FLVPlayback and using playWhenEnoughLoaded() gives the same results.
Is there a way to read the data from the DVD and put it on the local hard drive for a cache and then have the player play from that file? I would like to find a way to do this and somehow balance keeping the files on the DVD with smooth playback (otherwise, I have just have the user load 2.2 gigs worth of flv’s on the hard drive and I don’t want to do that.)
Thanks for the help.
Tim
November 27th, 2007 at 9:58 pm
To var …
AS3 is definitely the better organized and well thought out language. Glad to hear you’re having success with it!
To Tim …
I believe it’s possible to load FLVs that large — and in fact, I believe it was On2 itself that hosted Night of the Living Dead (billed as the first feature length FLV) early in the life of Flash 8 — but I have no idea how big that FLV was, and I’ve never tried it beyond, I think, 20MB or so.
To be honest, I don’t know if files on disc get cached the way online files do (my hunch is no, but I haven’t tested). As long as your FLVs are encoded with a reasonable bitrate (reasonable for DVD- or CD-ROM), I would think you’d be okay. You may need to throttle back a bit on that aspect.
Adobe’s Director (older, “big brother” of Flash) is capable of controlling DVD video directly, and for something like the file sizes you’re talking about, Director may well be the better choice. On its own, Flash doesn’t have a way to copy the files to the hard drive (again, unless caching happens … but like you said, loading that much data is just insane).
December 1st, 2007 at 5:57 am
This script is perfect; exactly what I needed. Now how do I delete the video from the stage? I want the script to read that I load the video, play the video, check to see if the video has stopped playing ad if so, delete the video and go to my desired frame.
Thanks!
Tess
December 2nd, 2007 at 10:36 pm
Tess,
When the video has completed playing, you don’t actually need to delete it. Going to another frame will effectively leave the video behind, forgotten. You may want to call
NetStream.close()and delete your instances (delete ns;,delete nc;, etc.), but you shouldn’t have to.December 7th, 2007 at 2:17 pm
“Migrating from AS2 to AS3 ranges anywhere from easy to mind-numbingly crazy, depending on any number of random factors.”
Are you a f—ing idiot? It’s not that complicated. This community is consistently and continually an embarrassment.
December 7th, 2007 at 3:26 pm
Carl,
By the sound of your comment, you haven’t had any migration issues. Count yourself lucky! We’re all on different levels, of course, and assessments of difficulty are unique for everyone.
December 14th, 2007 at 5:38 pm
I was wondering how I could take this code but make the file you have specified in the last part a variable so I can load it from the HTML in the page I will embed my swf in.
December 15th, 2007 at 12:12 am
Kyle,
The concept will be very similar to “How to Tell a SWF What File(s) to Load — From the Outside,” only, because that’s an AS2 article, you’ll have to read it, digest, then apply this AS3 update.
January 12th, 2008 at 1:03 pm
thanks for your help last time on may 31st 2007. here is another one! could u tell me the script to load my flv randomly on the main page of my “papajaypictures”? i am really impressed your help last time when i didn’t even know how to load flv! thanks!!
January 13th, 2008 at 1:29 pm
beryl,
I replied to your question on the AS2 version of this tutorial, so now I’m not sure what version of ActionScript you’re using.
See if my other reply makes sense for you, and let me know if it doesn’t.
January 22nd, 2008 at 7:15 am
hi David.
amazing the time and effort you put into this.
I have a similar question to Tess’ question.
when my video has stopped playing, I want to start the video over again, making it loop.
I guess I should be listening for some kind of event, but the use of the AS2.0-like Object puzzles me, and I can’t get my video to loop.
can you help me on this?
thanks
felisan
January 22nd, 2008 at 10:50 am
felisan,
Repeating your video clip won’t be too hard.
The “How to Determine the Completion of a Flash Video (FLV) File” article — at least, as of this writing (Jan 22, 08) — is written for ActionScript 2.0. It sounds like you need an AS3 solution, so here’s one in a nutshell:
The essentials of this approach are spelled out in “How to Play Flash Video Files (FLV) Sequentially” (see the first ActionScript 3.0 heading — I assume you’re going for the non-FLVPlayback approach, so let me know if I misjudged). This approach hinges on the
NetStatusEvent.NET_STATUSevent handler, which could be any event that fires repeatedly (such asENTER_FRAME, butNET_STATUSfires less often, which saves on processor cycles.January 22nd, 2008 at 3:02 pm
hi David.
you’re my hero - thanks for the wonderful help.
I added two lines of code to yours above, and everything worked without any problems.
I added an instance of a Video:
var videoPlayer:Video = new Video(720, 486);
and then added it to the dislaylist:
addChild(videoPlayer);
[Code snipped by David, for sake of brevity.]
I’m a little puzzled that your if-statement looks for the duration to be >= (duration - 0,5) instead of just duration.
I’ve tried it the other way around, and it made no difference on my 10 sec .flv.
but so far, you’re my man, and I guess you have a perfect reason for doing what you do
thanks for sharing knowledge, I’ll check out the other topics also.
thanks
felisan, Denmark
January 22nd, 2008 at 3:29 pm
felisan,
If you didn’t already have a Video object on the Stage, then you betcha, that would do it.
In AS2, it isn’t possible to instantiate a Video object with the
newkeyword, but it’s really handy in AS3!Feel free to fiddle with that number or drop it altogether. In some cases, other readers and I have found that
durationdoesn’t always seem to match the video’s actual length, so that extra nudge can help.Thanks for visiting the blog, felisan! I hope you find other articles just as useful.
Just keep in mind that not all of them are written with AS3 in mind.
January 22nd, 2008 at 8:18 pm
I’m having a problem loading an external flash video - it keeps looping!!! I’ve put stops the video itself - in my main swf file - i’ve unchecked Loop from the publish options - but it keeps looping - how do i get it to stop??? Please Help!
January 23rd, 2008 at 8:50 pm
Keith,
Nothing in the code causes the FLV to loop — you’d have to program it to do that — so … it’s hard to say!
In this case, you should be able to literally copy/paste the suggested code into a new, empty FLA and change only the name of the FLV being summoned. When you do that, you’re saying the video loops?
January 31st, 2008 at 1:48 pm
Keith,
This code works great! Thanks so much!
Now next question (similar to Tess’s above), I have an animation before the FLV plays, which works fine and then the movie loads. But after the movie is over, how do I make it automatically go to the next frame/scene and play that time line without having the viewer interact?
January 31st, 2008 at 3:45 pm
Carolyn,
For what you’re after, you’ll need to listen for a
completeevent. The syntax will depend on a) what version of ActionScript you’re using (I assume 3.0, given this particular blog entry) and b) what mechanism you’re using to display the the video (FLVPlayback or a Video object). Which of these are you using?January 31st, 2008 at 5:28 pm
I am using ActionScript 2.0 and FLVPlayback.
January 31st, 2008 at 8:35 pm
David,
Is there a way to abandon the FLv when you leave the frame? I have an Video loaded in but if a user leaves that particular frame without stopping the loaded video it keeps playing in the background. and then if they return to the video frame two videos overlap.
www.anotherstorymusic.com
February 1st, 2008 at 10:08 am
Carolyn,
Cool! Then this is your best bet: “How to Determine the Completion of a Flash Video (FLV) File (AS2)“.
Instead of the
trace()statements you’ll see in the example …… you’ll use
gotoAndPlay()with the relevant frame and/or scene information.February 1st, 2008 at 8:26 pm
Mike,
Check out the
NetStream.close()method. Just invoke that on yourNetStreaminstance (nsin the article suggested code) and you’ll be set.February 4th, 2008 at 11:59 am
Cool stuff,
Has anyone figured out how to capture an event when the flv is finished? I cant get the onPlayStatus event to fire?
My code
[..]
var customClient:Object = new CustomClient();
ns.client = customClient;
ns.play(filename);
[..]
class CustomClient {
public function onMetaData(info:Object):void {
trace(”metadata: “);
}
public function onCuePoint(info:Object):void {
trace(”cuepoint: );
}
public function onPlayStatus(info:Object):void {
trace (”onplaystatus - never fires on!! “);
}
}
February 6th, 2008 at 9:01 pm
bubbleboy,
Here’s a way you can do it in ActionScript 3.0, assuming a
NetStreaminstance name ofns, as used in the article:February 20th, 2008 at 12:09 pm
Hi David, i am new to flash especially as3.0. I have the same problem as Mike. From his page i see that he did not correct it.
So, for example on my page i have a button GALLERII that takes me at frame 45 in my scene.
In that frame i have a movie clip.
Inside the movie clip i use your method “a made-by-hand Video object?” to create some video player. The source for the ns is set by 3 buttons.
THE Problem is that when i click other buttons in my scene, the sound of the movie keeps playing.
I know that i am suppose to use ns.close(); somewhere, but where should i put it ??
I tried in another frame to use nameOfTheMovieClip.ns.close(); but i get an error: Cannot access a property or method of a null object reference.
So what can i do when i click and navigate to another frame to stop the movie from playing in the background. (the video player is inside the second frame of a movie clip who is in the frame 45 in my stage)
This error exists in Lynda com Flash CS3 Professional Essential Training (i used it to learn flash) , but is not obvious for them because they don’t have sound in the example videos, but if i check, the flash file is leaking memory.
February 22nd, 2008 at 4:11 pm
Hi David,
Can you please tell me where I can find an easy, step-by-step tutorial of how to encode Flash Video using Flash Pro 8 where the user can see the video and controller.
I am having great difficulties figuring out the detailed, exact, step-by-step process to accomplishing this task…
I’m trying to encode a video 640×480 plus an external controller…
You are very good so I hope you have a book that I can buy and follow to help understand this process…
Thank you!
February 22nd, 2008 at 8:31 pm
Carl,
It looks like you’re 90% there!
I visited your site and saw the video playing, but you’re right, the controller is missing. My hunch is that you’re using the FLVPlayback component — or that the Import Video wizard set up the FLVPlayback component for you — in which case you can probably see the controller when you test locally, but not on your website.
There are four files you need to upload when your work is done: a) the SWF that contains your video, b) the SWF the contains the controller, c) the FLV itself (the video), and d) the HTML page in which everything is embedded. It looks like you uploaded everything but B.
If my hunch is off, then let me know, but in the mean time, make sure all these files have been uploaded into the same folder on your website.
I haven’t written a video book myself, but I just finished tech reviewing Foundation Flash CS3 Video, by my good friend Tom Green and Adam Thomas. It’ll be in stores soon.
February 29th, 2008 at 11:38 am
Hi David,
I’m having problem with loading too many files from xml, and the flash is not possible to show it all.
http://www.giftsloving.com/mk2/
You can visit my site and click the “work” button. I didn’t expect the clients list would be that long, so, i extended the height of the stage but the scrollbar of browser appears…. Is it possible to add a flash scrollbar while loading the external xml.
Tried flash scrollbar b4 with loading just a simple text format file. but not like this time for loading info for individual buttons. Is it possible to do?
March 2nd, 2008 at 12:35 am
Thanks David! If you have time, I got it to work! http://djcarl.com/nsync.htm. The .swf, .flv and .fla files are in the video folder and the controller.swf is in the root directory where the index file resides…
Furthermore, where can I learn how to design a video player like one at Yahoo! where you can have multiple videos to select from on one page:
http://cosmos.bcst.yahoo.com/up/player/popup/?rn=3906861&cl=6733641&ch=4226713&src=news
March 2nd, 2008 at 7:42 pm
same problem as Mihai…
loaded flv continues to play after the user navigates away from the scene where the flv initiated playblack…how do i successfully close the netstream and send the user back to another scene?
stop();
//flv player
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var vid:Video = new Video(600, 400);
this.addChild(vid);
vid.attachNetStream(ns);
ns.play(”http://www.jeremydwright.com/video/DMSpodcast_final04.flv”);
ns.togglePause();
ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);
function netstat(stats:NetStatusEvent)
{
trace(stats.info.code);
if (stats.info.code ==”NetStream.Play.Stop”)
{
gotoAndStop( “block1″ , “Scene 1″);
}
}
var netClient:Object = new Object();
netClient.onMetaData = function(meta:Object)
{
trace(meta.duration);
};
ns.client = netClient;
//rewindButton
function rewind( pEvent:MouseEvent ):void
{
if( pEvent.target == rewindButton )
{
ns.seek(0);
}
}
rewindButton.addEventListener(
MouseEvent.CLICK, rewind );
//playButton
function playpause( pEvent:MouseEvent ):void
{
if( pEvent.target == playButton )
{
ns.togglePause();
}
}
playButton.addEventListener(
MouseEvent.CLICK, playpause );
//home Button
//event handlers
function handleClick2( pEvent:MouseEvent ):void
{
if( pEvent.target == home2 )
{
//handle the event
ns.close();
}
}
//register events
home2.addEventListener(
MouseEvent.CLICK, handleClick2 );
March 3rd, 2008 at 1:21 am
David,
Thanks for all your help! I have really learned a lot about Flash Pro 8 Video from your blog and your replies responding to my concerns and issues…
Now that I have 2 Flash Pro 8 videos online - (Digitized from VHS Tape)
(1) http://djcarl.com/nsync.htm?=nsync (2001 VHS tape) and
(2) http://resume.djcarl.com (1998 VHS tape)
Can Sorenson Squeeze 4.8 or Flash CS3 Pro, help to clean up the video deinterlacing and other issues I have in my online videos?
*If I purchased Sorenson Squeeze, what is the process (step-by-step) into creating an FLV for web playback?
*Would I use Squeeze “instead” of the Flash 8 Video Encoder or do I have to use both?
Thanks!!!
Carl Williams
March 25th, 2008 at 8:36 pm
Browser Effects Streaming Behavior (Downloads Whole .FLV before Playback)
Hi,
I am using this method to display video, but when delivered in a browser the behavior changes.
Everything works fine from the flash ide, or when running a swf. The progressive download works great, and the video begins playing while the flv is still loading
However, if I open it in a browser, It will always download the entire .flv before playback begins.
I have to deliver some quite long videos, so this is a real issue. The behaviour is the same when the .html and .fla is online, reading from a relative folder.
I am making sure to use:
nc.connect(null);
…to indicate a progressive download, as described above.
Has anyone had this problem?
Thanks,
-Lee
March 25th, 2008 at 9:25 pm
OK, this turned out to be something strange and probably very rare.
I had been playing with BulkLoader (which is great BTW):
http://www.stimuli.com.br/trane/2007/nov/25/loading-reloaded/
..to load my videos but had decided not to use it for now. However I was still adding my videos to BulkLoader during my xml read function using bLoader.add()
It did not occur to me right away that this might effect things, but when I removed that line everything performed as expected. I doubt this will come up for anyone very soon, but I thought I’d better add this follow up.
March 25th, 2008 at 10:40 pm
Lee,
Thanks for the follow up. When I read your first post, my immediate hunch was, “Something else must be going on,” and it sounds like you found it. Good on the troubleshooting!
April 3rd, 2008 at 10:47 pm
To Mihai …
That depends entirely on where everything is located — the code and the assets on the timeline, I mean.
If the
NetStreamcode is in a frame script of the movie clip in question, and if that movie clip’s scripted frame is the current frame of that clip, then your reference should work — but do you see how the planets have to align, so to speak, in order for you to achieve success?Really, it comes down to making valid object references. It sounds like you have a window of opportunity at some point, because you’re able to get the video to play in the first place. Of course, your code is inside the movie clip in question … but you should be able to put your
NetStreamcode in the main timeline, which will likely decrease the complexity involved in making your object reference.The “simple” answer, really, is that you need to invoke
NetStream.close()on the relevantNetStreaminstance, but your headache may be finding that instance. I wish I could help more! Unfortunately, it has taken me so long to reply — I can’t really visualize your file structure — that I’m not sure my response will be useful to you … but I hope so!To Emily …
Yes, you can use the UIScrollBar for text, but if you’re creating buttons and/or other non-text content and need to scroll that, the ScrollPane component is your key.
To Carl …
There are numerous ways to go about building that sort of functionality (Emily did something similar on her website, for example) — the trick, really, is to make a proper object reference to your
FLVPlaybackorNetStreaminstance and invoke the necessary loading method each time. You can program hyperlinks to trigger that for you from an HTML-formatted text field, or from buttons, or whatever you like.That Yahoo! player, of course, is very nicely done and presumably took a while to program, but in princple the goal isn’t difficult to achieve.
In my experience, yes, Squeeze will help take care of that interlacing. Flash won’t really do it on its own. There’s another 3rd party encoder, Flix Pro, that’s worth looking into, too.
You’ll find a couple tutorials at CommunityMX.com, where I also write tutorials (these are by a friend of mine, Derrick Ypenburg).
http://www.communitymx.com/abstract.cfm?cid=AD6C6
To access that particular article, you’ll have to sign up for a non-obligatory trial membership, which gets you access to everything. If you like what you see, consider becoming a member! But in any case, that should get you a good head start.
Yes. Using Squeeze or Flix Pro results if your having an FLV file, which you then use with your component or Video object.
To JDW …
In whatever code navigates to a new frame, leave your
gotoAndPlay()in place, but precede that line withns.close().April 11th, 2008 at 4:54 am
Hi Dave, I’m having a big problem and if you were able to help I would be most grateful.
I’ve created a player using the same steps as you did, in AS3, but I’ve been trying to make it load on mute and making the video on a continuous loop. Do you have any idea on how I can achieve this?
Thank you in advance.
April 25th, 2008 at 2:50 pm
Ricardo,
I think you’re asking how to load the video and display it silently — then have it loop. If that’s it, here’s your code:
The looping is handled by the
netStatusHandler(), and in AS3, theNetStreamclass happens to have asoundTransformproperty, which points to its own personalSoundTransforminstance. Change thevolumeproperty of that, and associate that back to theNetStreaminstance.August 7th, 2008 at 6:56 am
Hello, this script helped me quite a lot, but I have a problem…. I need to display a video at a specific size (lets say 300×300), but the source video is 500×500… is there any way resizing the video?
In current configuration I ged only top left corner of a video
thanks,
nejck
August 9th, 2008 at 10:04 pm
nejck,
In my experience, the size if the video is determined by the parameters you pass into the
Videoconstructor. When I do this, for example:… I get a video that’s 320 x 240, even if the actual FLV is bigger. It should be happening for you.
Is your Video object somehow getting masked?