| By Stefan Richter | Article Rating: |
|
| October 18, 2005 09:00 AM EDT | Reads: |
16,550 |
We probably all know by now how to play a progressive FLV without Flashcom:
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(my_nc);
ns.setBufferTime(0.1); // small buffer to limit motion in preview
my_video.attachVideo(ns); // my_video is a video object on stage
ns.play(thefile);
To turn this example into a thumbnail preview of the actual FLV you could do this:
There's even a way of supressing the sound resulting in a silent preview:
ns.onStatus = function (info) {
if(info.code == "NetStream.Buffer.Full"){
ns.pause();
}
};
// soundholder is a simple movieclip on stage
soundholder.attachAudio(ns);
audio = new Sound(soundholder);
audio.setVolume(0);
You don't have to be a rocket scientist to take this example further using a 'play' button and kicking the video plus sound into life upon click. But what's not so obvious is the fact that even if you pause the video, the FLV file will load in its entirety in the background, potentially clogging up a user's connection. This is even more of an issue if you want to display many previews at once.
I found out about this behavior using a neat little program called Netlimiter (www.netlimiter.com/). It allows you to see which applications are using what kind of bandwidth and it also enables you to throttle a fast connection on a per application basis, emulating dialup users for example.
I thought it would be easy enough to stop the FLV downloading by killing the NetConnection or close the NetStream similar to how this would work using Flashcom. Unfortunately I had no success with that approach, the FLV would continue downloading come what may.
Fortunately the workaround was surprisingly easy: try loading a non-existing FLV. Here's the code I used:
This seems to do the trick quite nicely, showing one frame of the previously loaded FLV without clearing the video object. A typical preview consumed only about 5 to 10 KB of data -- a big saving over a whole flv file which is potentially several MB in size.
ns.onStatus = function (info) {
if(info.code == "NetStream.Buffer.Full"){
my_video.attachVideo(null);
ns.pause();
ns.play("nonexist.flv");
}
};
The source for the finished example is here: www.flashcomguru.co.uk/downloads/flv_preview.zip
The sourcecode is a bit messy but I didn't have time to clean it up.
Let me emphasize again: if you only have a single FLV file on your page then the background download can be a great feature and even improve the user experience. But if you want to preview many different FLV files on one page then I recommend you use my approach above.
Hope this helps someone.
Published October 18, 2005 Reads 16,550
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Stefan Richter
Stefan Richter is a Certified Flash Developer and Team Macromedia member who has been involved with Flash Communication Server since its early days. As VP of Application Development and cofounder of POPview, he has developed a variety of Rich Internet Applications using Flash Communication Server, Flash MX 2004 and Coldfusion. You can find more of Stefan's articles at www.flashcomguru.com.
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Executives Feature on Cloud Computing Expo Power Panel
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Reader Sued
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Ph.D. in Twitter Anyone?
- Adobe Flex Developer Earns $100K in New York City
- Eolas Sues the Internet
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Special Report on the Emerging Cloud Computing Trend
- My Thoughts on Ulitzer
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Ulitzer Live! New Media Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Executives Feature on Cloud Computing Expo Power Panel
- Software Flexibility in the Cloud - Part 4 of 5
- Is Microsoft as Free as Open Source?
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Reader Sued
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Where Are RIA Technologies Headed in 2008?
- Cover Story: How to Increase the Frame Rates of Your Flash Movies
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Your First Adobe Flex Application with a ColdFusion Backend
- Adobe Flex 2: Advanced DataGrid
- i-Technology Blog: Death-Knell For "Rich Media? Hardly!
- Adobe/Macromedia - Microsoft, Look Out!
- How To Create a Photo Slide Show ...
- Adobe Flex Interface Customization - Themes, Styles, Skins
- Personal Branding Checklist
- Has the Technology Bounceback Begun?
- "Real-World Flex" by Adobe's Christophe Coenraets



































