PDA

View Full Version : Tweeking Dynamic streaming playlist (XML &FCS)


PhishIn4Dmb
11-10-2005, 12:57 PM
Hey all:

I am trying to tweek out a tutorial from Macromedia that deals with dynamic XML video list. It poppulates a list with a thumb nail from a FLV file that is hosted on a FCS.

I am getting ready to use a shared FCS server but considering how expensive it I can only affoard a very limited account. The problem is when the SWF poppulates the list componet it opens a STREAM to the server to get a thumbnail image of the FLV file. In doing so it leaves the stream open which is where the problem comes in.

I am limited to 5 streams from the FCS. Is there a easy way close the stream after it has got the thumbnail and cache it so it can free up the streams?

Right now the list has 4 videos in it, and when a thumbnail is selected it plays the video which in tottaly is 5 streams. I am sure this is a easy fix, but It is beyound me (after 3 days of trying)

The only way I got it to work is to actually make my own Thumbnails, but that kinda of defeats the purpose of a Dynamic playlist.

here is the code that creates the thumbnails. THANKS FOR ANY HELP.



class VideoThumb extends mx.core.UIComponent
{
static var symbolName = "VideoThumb";
var label : Object; // the new text label we'll use
var listOwner : Object; // reference to the tree - supplied by the tree
var thumb;
var nc; // NetConnection
var ns; // NetStream
var streamurl;

function VideoThumb()
{
// nothing needed - we're extending v2;
}

function init()
{
// nothing needed - we don't have any instance variables to initialize
}

function createChildren(Void) : Void
{
var v = this.attachMovie( "VideoHolder", "thumb", 0 );
v._width = 67;
v._height = 45;
v.styleName = listOwner;

var c = createLabel("label", 1);

c.styleName = listOwner;
c.selectable = false;
}

// pass all sizing from the tree to the cell
function size(Void) : Void
{
label.setSize(label.getPreferredWidth(),label.getP referredHeight());
label._x = thumb._width + 10;
label._y = thumb._height/2 - label._height/2;
}

// str is the suggested string to render from the tree (based on the node)
// node is the entire XMLNode for the row
// sel is the selected state (not usually used)
function setValue(str : String, item, sel)
{
_visible = item != undefined;
if ( !_visible )
return;

label.setValue( item.attributes.name );

// Thumbnail is picked up as the first frame of the playlist
var url = item.attributes.url;
var stream = item.attributes.thumb;
var start = item.attributes.thumbpos;

// If explicit thumb is not specified use the
// start frame of the first stream
if ( stream == undefined ) {
stream = item.childNodes[0].attributes.name;
start = item.childNodes[0].attributes.start;
}

// Give up if we still don't have valid thumb info
if ( stream == undefined )
return;

// Render the thumbnail only if necessary
if ( streamurl == url + "/" + stream )
return;

streamurl = url + "/" + stream;
//trace( streamurl );

nc = new NetConnection();
//nc.onStatus = function( info ) { trace( info.code ); }
nc.connect( url );

ns = new NetStream(nc);
ns.onStatus = function(info) {
if ( info.code == "NetStream.Play.Stop" ) {
nc = null;
ns = null;
}
}
thumb.video.attachVideo(ns);
ns.connect();
ns.play( stream, start, 0 );
}

// ensures the cell is centered vertically properly - luckily, the label also implements this method.
function getPreferredHeight()
{
return 60;
}

function getPreferredWidth()
{
return label.getPreferredWidth();
}
}