PDA

View Full Version : loading and unloading FLVs from FLVPC


madmac66
03-07-2008, 07:00 PM
Hi, I have an instance of the FLVPlayback Component on my stage that is populated by ActionScript. I have a button that when clicked loads 1 of 3 possible FLVs using contentPath() property. When the FLV is complete, I have a listener that unloads the movie and initiates the menu once more.

Everything works fine the first time round. however once the movie has been unloaded, no other movie can be loaded in. If I use stop() with the listener in place of unload movie, further FLVs can be successfully loaded in, but obviously this looks terrible as I have the menu viewing over the frame of video.

So, how do i successfully unload an FLV then load another back in?

I have menu_mc on the root timeline that has all the code that looks like this... the variables that decide which FLV to load (nextSeg) are created on a previous frame.



stop();
import mx.video.*;
trace("playing:"+nextSeg);

_root.main_flv.load("video/"+nextSeg+".flv");
_root.main_flv.play();
//_root.main_flv.contentPath = "video/"+nextSeg+".flv";

_root.return_btn._visible = true;
_root.replay_btn._visible = false;

var listenerObject:Object = new Object();

listenerObject.ready = function() {
menuCube_mc._visible = false;
}
listenerObject.complete = function() {
_root.main_flv.unloadMovie();
menuCube_mc._visible = true;
_root.menu_mc.gotoAndPlay(1);
}

_root.main_flv.addEventListener("ready", listenerObject);
_root.main_flv.addEventListener("complete", listenerObject);

atomic
03-07-2008, 08:24 PM
Why are you unloading it? Just make it invisible when you make your menu visible, change it's content path and make it visible again when needed...

madmac66
03-07-2008, 10:12 PM
Why are you unloading it? Just make it invisible when you make your menu visible, change it's content path and make it visible again when needed...

Yeah thats what I have resigned to doing. I thought there might be a more elegant way to do it. Who knew I already had the answer :)

cheers

atomic
03-07-2008, 10:22 PM
I did! You should of asked! ;)

madmac66
03-20-2008, 11:05 PM
Returning to this old thread, I have used visiblity to show and hide the FLVPC as necessary. But I have just noticed another bug that I cannot get past.

Basically I have a menu with 3 choices, select one and it hides the menu and shows the FLVPC and loads in an FLV by the value of a variable. All on one frame.

The FLV plays fine. The FLV plays to the end, a listener then hides the FLVPC and shows/plays the menu. There is also a return_btn that stops the FLV, hides the FLVPC and shows/plays the menu.

The problem arises when I immediately select play for the FLV that just completed. It will not play having already played. If I choose another menu item, it plays fine. And the first menu item will play fine AFTER the other FLV has been selected. Just wont play twice in a row.

Not a huge deal, but a bug that my client will eventually find an want fixed. I've looked for ways to rewind or stop or close the FLV, but nothing that works with my setup.


cheers
mm66

atomic
03-21-2008, 01:53 AM
Attach your .fla.

madmac66
03-21-2008, 05:26 PM
Here is an FLA with some assets removed for NDA purposes. Functionality is still there. No FLVs though (would be too big).

Cheers a million
mm66

madmac66
03-21-2008, 06:20 PM
Well silly me, turns out the FLVPC needs a play() command to start it up again. Just sending it the contentPath does not start the same FLV from the beginning.

On the other hand, now I have another issue (fix one bug, find another...).

The event listener "playing" leaves some overlap between hiding the 'dummy cube' and the visible FLVPC. By that I mean, there is a frame or two when both objects are visible, ideally I would like the dummy to hide then immediatly show the FLVPC. The event listener "ready" does this perfectly, but only once, the first time. Obviously once the FLV is loaded into the component it is ready, and will continue to be ready until another FLV replaces it via contentPath.

So I get back to my original question, how to unload an FLV, to reinitialize the FLVPC and allow it to be "ready" a second time in a row.

Good lord I hope this makes some sense, feel like i'm rambling on.

Any advice is always welcome, I'm reading up on the FLVPC class right now.

cheers
mm66

madmac66
03-21-2008, 07:43 PM
once more I will answer my own question. I ended up using


_root.main_flv.activeVideoPlayerIndex = 1;
_root.main_flv.visibleVideoPlayerIndex = 1;


to set up a new stack in the component and then closing it with this


_root.main_fl.closeVideoPlayer(1)


Works!
mm66

atomic
03-21-2008, 08:44 PM
One's never better served than by one's self! ;)

Happy Easter!

madmac66
03-21-2008, 11:23 PM
Yessir, to you to.

Cheers