View Full Version : How change FLVPlayback contentpath?
robertnzana
01-19-2006, 06:12 PM
I have an FLVPlackback component to black videos.
How do I get an FLV name passed by a parameter (or another easy way?) to the swf movie and load it into the contentpath property of the video player?
I basically want my player to be able to switch movies as a result.
FYI: 1.flv, 2.flv and 3.flv are movies located in the SAME dir as the fla/swf.
Thanks.
Paerez
01-19-2006, 06:53 PM
for, "passed as a parameter" do you mean javascript or GET/POST?
robertnzana
01-19-2006, 06:57 PM
No javacript. I am an ASP.NET developer so GET/POST would be best, unless there's a better way (xml file, etc...) Thanks.
Paerez
01-19-2006, 07:12 PM
You can use the XML.load(url) to load an xml file from a remote url, and then use Flash's built in XML parser to grab your data.
robertnzana
01-20-2006, 03:00 AM
how can i set the content path? it doesn't seem to change when i do flvplayer.contentpath=myvar?
Paerez
01-20-2006, 03:47 AM
its flvplayer.load(url), not contentPath.
robertnzana
01-20-2006, 03:57 AM
its flvplayer.load(url), not contentPath.
I tried that. I created a FLVPlayback component and named it 'MyPlayer'. I left the contentPath empty. I created a button and put this actionscript in it:
on(press)
{
MyPlayer.load("C:\Flash\sandbox\1.flv");
}
But, nothing happens. Any ideas? Thanks!
rockman2023
01-20-2006, 04:33 AM
Sorry for the bump, but I seem to have the same issue with trying to load any .flv dynamically. I'm using the following code:
var file:String = new String(dir+itemAr[k]);
// 'dir' is the directory where the external content is at
// 'itemAr' is the array that contains the filenames of the external content (gathered from XML file)
import mx.video.*;
kiosk.holder.myFLVP.load(file);
trace(kiosk.holder.myFLVP.contentPath)
If I trace the contentPath, it returns the correct path. However, the flv doesnt not load at all. What's strange is that if I hard-code the url to be loaded
kiosk.holder.myFLVP.load("files/mk.flv");
the file will load as intended.
rockman2023
01-20-2006, 05:14 AM
Well, I've managed to get this working via a workaround. I don't know if this helps you Rob, but I think it should.
In my situation, I have my portfolio.swf loading in another swf, playback.swf, that contains the FLVPlayback component. I have the following code in the portfolio.swf:
function fadeKiosk(k){
// ...code...
mcLis.onLoadInit = function(){
kiosk.holder.playMe(k);
}
}
In the code above, when playback.swf is finished loading into kiosk.holder, it's told to call the function playMe() and has paramater k (which is the numerical index in the array that contains the file names from my XML) passed to playMe(). Remember, playMe() is defined in playback.swf, and since it was loaded into kiosk.holder, it can be accessed:
import mx.video.*;
function playMe(file) {
switch (file) {
case 12 :
myFLVP.load("files/enjoy.flv");
break;
case 13 :
myFLVP.load("files/mk.flv");
break;
case 14 :
myFLVP.load("files/space.flv");
break;
case 15 :
myFLVP.load("files/demo.flv");
break;
}
myFLVP.play()
}
The case numbers refer to the number index in the array created from my XML data; these will be different in your situation. In essence, the url to be loaded is still hard-coded, but by using the switch/case statement, you can still get your flv dynamically.
I seriously hopes this helps. You can check out the progress at http://www.vectorelement.com/s2/
robertnzana
01-20-2006, 02:03 PM
Great idea. I might try that. But, this is what I'm actually trying to do...
I'm making a website with members. Members can have up to 10 videos (FLV only). The user selects a member then they can access the member's videos. So, it may be 1, 2... to 10 videos. Any ideas on to a solution for a nice interface?
Thanks again!
Paerez
01-20-2006, 02:44 PM
The project I am working on uses a SQL data that stores all the file paths. Here is my code for loading the data into the component:
var selectItem = function (file:Array) {
video.stop();
image.invalidate();
if (file == undefined || file == null) {
video._visible = false;
image._visible = false;
} else {
var mediaID = file[0];
var isImage:String = file[3].charAt(file[3].indexOf("image"));
var isAudio:String = file[3].charAt(file[3].indexOf("audio"));
var isVideo:String = file[3].charAt(file[3].indexOf("video"));
var isFlash:String = file[3].charAt(file[3].indexOf("flash"));
if (isImage == "i") {
video._visible = false;
image._visible = true;
preLoader._visible = true;
preLoader.setPercent(0);
image.load(_global.viewURL + siteID+"/"+mediaID+"_lg.jpg");//"+ext);
trace("Image Loading = "+_global.viewURL + siteID+"/"+mediaID+"_lg.jpg");//+ext);
}
if (isAudio == "a") {
image._visible = false;
video._visible = true;
preLoader._visible = false;
video.setMedia(_global.viewURL + siteID+"/"+mediaID+".mp3");
trace("Media = "+file[1]+" Loading from = "+_global.viewURL + siteID+"/"+mediaID+".mp3");//+ext);
}
if (isVideo == "v") {
image._visible = false;
video._visible = true;
preLoader._visible = false;
video.setMedia(_global.viewURL + siteID+"/"+mediaID+".flv");
trace("Media = "+file[1]+" Loading from = "+_global.viewURL + siteID+"/"+mediaID+".flv");//+ext);
}
if (isFlash == "f") {
video._visible = false;
image._visible = true;
preLoader._visible = true;
preLoader.setPercent(0);
image.load(_global.viewURL + siteID+"/"+mediaID+".swf");//"+ext);
trace("Media = "+file[1]+" Loading from = "+_global.viewURL + siteID+"/"+mediaID+".swf");//+ext);
}
if (isVideo == "v" || isAudio == "a" || isImage == "i" || isFlash == "f") {
pleaseSelect._visible = false;
}
}
};
note: this is for loading images, music, video, and swfs dynamically into a media component, given the "file" object, which contains a lot of data. We use the ID number from the DB to give us the path.
So I guess the correct function was setMedia(url)
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.