Changing contentPath with button?
- 16Bits
-
16Bits
- Member since: Oct. 7, 2008
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
I have an instance of the FLV Playback component on stage.
I want to change what video gets loaded into the player based
on which button is selected.
My guess is it has something to do with updating the contentPath in the FLV playback parameters, but I'm not sure how (Assuming it's possible) to go about it.
Any thoughts?
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
At 3/4/09 11:49 PM, 16Bits wrote: I want to change what video gets loaded into the player based
on which button is selected.
I built a YouTube-style video player a while back, I can't remember exactly how it all works, but here's some relevant code:
import mx.video.NCManager;
import mx.video.VideoPlayer;
var _dummy:NCManager;
var VP:VideoPlayer;
flvName="Video01";
b_play.onPress=function(){
if(VP.playheadTime==VP.totalTime){
VP.playheadTime=0;
}
VP.bufferTime=1;VP.width=400;VP.height=320;VP.autoRewind=false;
VP.addEventListener("progress",LoadProg);
VP.addEventListener("complete",EndIt);
VP.play(_root.flvName+".flv");
}
function LoadProg(eventObj:Object):Void{
PC=VP.bytesLoaded/VP.bytesTotal*100;
loadBar._xscale=PC;
}
function EndIt(eventObj:Object):Void{
pausd=1;b_pause._visible=0;b_play._visible=1;
}
onEnterFrame=function(){
if(!pausd){
playBar._xscale=(VP.playheadTime*1000)/(VP.totalTime*1000)*100;
if(stopd){stopd=0;VP.play();}
}else{
VP.pause();
stopd=1;
}
}
I guess to choose different videos you should just be able to create an array of the flv filenames/paths (in quotes) and pull an item out of that array for the flvName variable.
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
At 3/5/09 03:32 AM, Denvish wrote: here's some relevant code:
There's some irrelevant code in there too, eg stopd and b_pause, the Instance Name of the MC on stage was VP (set to Class: mx.video.VideoPlayer in the library). The Video component itself is set to Video (Actionscript-controlled) in the library properties, and placed inside the VP MC.
Hope that sort of makes sense - if not, try this (set to import from a flv filename variable appended to the swf eg VPlayer.swf?flvName=Video01 - should be adapted easily enough)


