Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Articles Thread, Generating thumbnail previews using progressive flvs in Flash Media Server; We probably all know by now how to play a progressive flv without FMS: PHP Code:          nc = new NetConnection ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=3581


Reply
LinkBack Thread Tools Display Modes
Generating thumbnail previews using progressive flvs
 
 
Choose
SABRAWY's Avatar

Reply With Quote
 
Join Date: Aug 2007
Posts: 1,893
17-09-2008, 08:47 AM
 
We probably all know by now how to play a progressive flv without FMS:
PHP Code:
         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:

PHP Code:
         ns.onStatus = function (info) {
     if(
info.code == "NetStream.Buffer.Full"){
          
ns.pause();
     }
};

There's even a way of surpressing the sound resulting in a silent preview:

// 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 behaviour using a neat little program called Netlimiter. 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.

Furtunately the workaround was suprisingly easy: try loading a non-existing flv. Here's the code I used:
PHP Code:
ns.onStatus = function (info) {
     if(
info.code == "NetStream.Buffer.Full"){
          
my_video.attachVideo(null);
          
ns.pause();
          
ns.play("nonexist.flv");
     }
};
This seems to do the trick quite nicely, showing one frame of the previously loaded flv without clearing the video object. A typical preview only consumed about 5kB to 10 kB of data - a big saving over a whole flv file which is potentially several MB in size.





Download source

The sourcecode is a bit messy but I couldn't be bothered to clean it up :-P

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.

This Artical by Stefan Richter
Attached Files
File Type: zip flv_preview.zip (99.6 KB, 1 views)
 
 
 
Reply

Articles Thread, Generating thumbnail previews using progressive flvs in Flash Media Server; We probably all know by now how to play a progressive flv without FMS: PHP Code:          nc = new NetConnection ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=3581


Bookmarks

Tags
flvs, generating, previews, progressive, thumbnail


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating simple reports from a table Developer Articles 0 26-11-2008 09:21 PM