davinepictures
10-24-2006, 05:22 PM
Hi, I'm in need of help with this actionscript.
I'm trying something like Proxus where there is a dynamic playlist using xml list to load into an flv playback component in flash 8 professional. Where Proxus is using php and alot of other stuff I'm using actionscript. Is this even possible??? I'm doing this for Progressive Download. I have been trying to figure out the actionscript in which the video would load into an FLV playback component when chosen from the play list. I have been able to get to the point where choosing the play list will come out with the flvplayback component but for some reason I can't seem to get any of the video to load at all into the flvplayback component. (note: the video must be able to be controlled (pause, stop, play, etc.) WHAT AM I DOING WRONG! (sorry five days and stressing out over this)
All of this that I've done is with tutorials from adobe devnet (dynamic playlist for progressive download) and trial and error. IF anyone ANYONE PLEASE PLEASE HELP ME! I've just totally hit a brick wall. Also just to say thanks for your time.
Here is the actionscript code:
//Set up the list box, call function VideoThumb to create the actual thumbnails
list.rowHeight = 70;
list.cellRenderer = "VideoThumb";
list.selectable = true;
//create new empty listener object
listListener = {};
//Function to handle what happens when an item in the list is selected
listListener.change = function( evtobj ) {
var nav = list.dataProvider[list.selectedIndex];
nc = new NetConnection(); //create a connection
nc.connect( null ); //null connection for progressive download
ns = new NetStream(nc); //create a stream
video.attachMovie(ns); //pipe stream to this video object
// walk through the chosen item, build and play it
var reset = true;
for ( var i = 0; i < nav.childNodes.length; i++ ) {
var stream = nav.childNodes[i];
if ( stream.nodeName == "stream" ) {
// build path to flv, and play it
listListener.change = function( evtobj ) {
var reset = true;
for ( var i = 0; i < nav.childNodes.length; i++ ) {
var stream = nav.childNodes[i];
if ( stream.nodeName == "stream" ) {
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);
};
my_FLVPlybk.skin = "SteelExternalAll.swf";
my_FLVPlybk.clear();
my_FLVPlybk.contentPath = nav.attributes.url + "/_definst_/" + stream.attributes.name+".flv";
my_FLVPlybk.autoSize = true;
//trace(my_FLVPlybk.contentPath);
reset = false;
}
}
}
}
}
}
//Add an event listener on the list, when it triggers, run the listListener function to repopulate the list
list.addEventListener("change", listListener);
//Function that loads the XML file, parses it, and builds the list of available video clips
var xmllist = new XML(); //setup a variable to hold the XML
xmllist.ignoreWhite = true;
xmllist.load( "playlist-demo-1.xml" ); //load the XML file
//The following gets called when the XML has been loaded
xmllist.onLoad = function( status ) {
if ( !status )
trace( status );
var entries = this.childNodes[0];
var playlists = {};
var nav = [];
for ( var i = 0; i < entries.childNodes.length; i++ ) {
var entry = entries.childNodes[i];
if ( entry.nodeName == "listitem" )
//builds array of video clip names
playlists[entry.attributes.name] = entry;
else if ( entry.nodeName == "menu" ) {
//builds array of available videos
for ( var j = 0; j < entry.childNodes.length; j++ )
nav[j] = playlists[entry.childNodes[j].attributes.name];
} //end else if
} //end if
//sends the array of videos to the listbox UI
list.dataProvider = nav;
} //end xmllist.onload
//resizes the video object to the width and height of the clip
function onVideoResize() {
if ( video.width != video._width || video.height != video._height ) {
video._width = video.width;
video._height = video.height;
//center video in playback area
newx = (460 - video._width)/2;
newy = (470 - video._height)/2;
video._x = newx;
video._y = newy;
}
}
setInterval( onVideoResize, 200 ); //keeps checking video size
I'm trying something like Proxus where there is a dynamic playlist using xml list to load into an flv playback component in flash 8 professional. Where Proxus is using php and alot of other stuff I'm using actionscript. Is this even possible??? I'm doing this for Progressive Download. I have been trying to figure out the actionscript in which the video would load into an FLV playback component when chosen from the play list. I have been able to get to the point where choosing the play list will come out with the flvplayback component but for some reason I can't seem to get any of the video to load at all into the flvplayback component. (note: the video must be able to be controlled (pause, stop, play, etc.) WHAT AM I DOING WRONG! (sorry five days and stressing out over this)
All of this that I've done is with tutorials from adobe devnet (dynamic playlist for progressive download) and trial and error. IF anyone ANYONE PLEASE PLEASE HELP ME! I've just totally hit a brick wall. Also just to say thanks for your time.
Here is the actionscript code:
//Set up the list box, call function VideoThumb to create the actual thumbnails
list.rowHeight = 70;
list.cellRenderer = "VideoThumb";
list.selectable = true;
//create new empty listener object
listListener = {};
//Function to handle what happens when an item in the list is selected
listListener.change = function( evtobj ) {
var nav = list.dataProvider[list.selectedIndex];
nc = new NetConnection(); //create a connection
nc.connect( null ); //null connection for progressive download
ns = new NetStream(nc); //create a stream
video.attachMovie(ns); //pipe stream to this video object
// walk through the chosen item, build and play it
var reset = true;
for ( var i = 0; i < nav.childNodes.length; i++ ) {
var stream = nav.childNodes[i];
if ( stream.nodeName == "stream" ) {
// build path to flv, and play it
listListener.change = function( evtobj ) {
var reset = true;
for ( var i = 0; i < nav.childNodes.length; i++ ) {
var stream = nav.childNodes[i];
if ( stream.nodeName == "stream" ) {
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);
};
my_FLVPlybk.skin = "SteelExternalAll.swf";
my_FLVPlybk.clear();
my_FLVPlybk.contentPath = nav.attributes.url + "/_definst_/" + stream.attributes.name+".flv";
my_FLVPlybk.autoSize = true;
//trace(my_FLVPlybk.contentPath);
reset = false;
}
}
}
}
}
}
//Add an event listener on the list, when it triggers, run the listListener function to repopulate the list
list.addEventListener("change", listListener);
//Function that loads the XML file, parses it, and builds the list of available video clips
var xmllist = new XML(); //setup a variable to hold the XML
xmllist.ignoreWhite = true;
xmllist.load( "playlist-demo-1.xml" ); //load the XML file
//The following gets called when the XML has been loaded
xmllist.onLoad = function( status ) {
if ( !status )
trace( status );
var entries = this.childNodes[0];
var playlists = {};
var nav = [];
for ( var i = 0; i < entries.childNodes.length; i++ ) {
var entry = entries.childNodes[i];
if ( entry.nodeName == "listitem" )
//builds array of video clip names
playlists[entry.attributes.name] = entry;
else if ( entry.nodeName == "menu" ) {
//builds array of available videos
for ( var j = 0; j < entry.childNodes.length; j++ )
nav[j] = playlists[entry.childNodes[j].attributes.name];
} //end else if
} //end if
//sends the array of videos to the listbox UI
list.dataProvider = nav;
} //end xmllist.onload
//resizes the video object to the width and height of the clip
function onVideoResize() {
if ( video.width != video._width || video.height != video._height ) {
video._width = video.width;
video._height = video.height;
//center video in playback area
newx = (460 - video._width)/2;
newy = (470 - video._height)/2;
video._x = newx;
video._y = newy;
}
}
setInterval( onVideoResize, 200 ); //keeps checking video size