How to stop the FLVPLAYER, when navigating to a diff page?

  • FlyHigh5
  • Newbie
  • Newbie
  • User avatar
  • Posts: 14

Post 3+ Months Ago

Hi,

I have a site, with a page dedicated to a video, which is an external XML driven video player, and I am Loading it into my site, using Load functionality (AS3).

The page is triggered via a button.

The problem I'm having is that if I Play the video and while the video is playing, click on a different button on the menu, and go to a different page, the video is still playing in the background and the sound can be heard.

I have similar issue if I use the Flash FLVPlayer.

What would I need to do, in order to tell the Player to stop playing, if another button is clicked? This is an external Swf!
With my limited knowledge of AS3, I can't find a solution to this.

I appreciate your help.

Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

In the release code for all your buttons pause the instance name of the video player or the movieclip target you load into. For example:

Code: [ Select ]
myFlvPlaybackInstanceName.pause();
  • FlyHigh5
  • Newbie
  • Newbie
  • User avatar
  • Posts: 14

Post 3+ Months Ago

Thanks for your response graphixboy. I tried your suggestion, but I'm afraid it didn't work. Could you please tell me what I'm doing wrong?

Here are the two ways I tried your solution.

First, in the AS, which I control the different states of my buttons, I added the pages.myMovie.pause(); to the down states of all of my other buttons. This resulted in having the movie to play fine, but I was unable to click on any of my other buttons. The down state for them was no longer functioning.

The way my buttons are structures are as follow:
I have a movie clip which contains all of my buttons. The AS controls the buttons. An example for one would be:

///////// BUTTON 1 CLICK FUNCTIONS
function mainBtn1Over(event:MouseEvent):void {
mainBtn1.gotoAndPlay("over");
}
/////////
function mainBtn1Out(event:MouseEvent):void {
mainBtn1.gotoAndPlay("out");
}
/////////
function mainBtn1Down(event:MouseEvent):void {
//pages.myMovie.pause(); <<----- This resulted in my down not functioning
mainBtn1.gotoAndPlay("down");
pages.gotoAndPlay("page1");
}

Pages is another movieclip, that I control all my pages and add some animation as they get displayed. Each page in Pages Movieclip, has its own movie clip (page1, page2,...) and the code to load the content can be seen in the example below.


Then I thought I will add this when I'm actually loading the contents of these pages(most of my pages are getting loaded, using the following code:)

import flash.events.Event;
import flash.events.IOErrorEvent;
import flash(dot)net.URLLoader;
import flash(dot)net.URLRequest;
import flash.display.Loader;

var swfLoader = new Loader();
var urlReq:URLRequest = new URLRequest("page1.swf");

pages.myMovie.pause();

swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadComplete);
swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
swfLoader.load(urlReq);

function swfLoadComplete(evt:Event):void
{
var loader:Loader = Loader(evt.target.loader);
addChild(loader.content);
swfLoader.removeEventListener(Event.COMPLETE, swfLoadComplete);
}

function swfLoadError(evt:IOErrorEvent):void
{
trace("Unable to load swf ");
swfLoader.removeEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
}

I had the following error message:

1120: Access of undefined property pages.


myMovie is the instance name I have given to my page 2, in Pages movieclip, which loads my video.

I hope this helps in clarifying how my code is structured.

Thanks.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Sorry I haven't been around. If you haven't gotten this figured out yet. I think the problem might be that I thought you were playing an flv file and not a swf. (In that cause pause()) won't work.

Instead try loader.stop(); when you goto a new page.
  • FlyHigh5
  • Newbie
  • Newbie
  • User avatar
  • Posts: 14

Post 3+ Months Ago

Welcome back and thanks again! I guess my problem is not knowing flash enough to find a way to access the loader that loads my Video, at the root level(if this is the right term to use!!??).

All my pages are loaded into my program, including my video. So each page has its own loader, therefore loader is a variable that is not defined globally. In order for me to stop my video from playing as I navigate to a different page, I need to be able to access the loader but it's not recognizable to my Page navigation movie clip, which is at a higher level in the stack.

Here's the page for loading the video:

import flash.events.Event;
import flash.events.IOErrorEvent;
import flash(dot)net.URLLoader;
import flash(dot)net.URLRequest;
import flash.display.Loader;

var swfLoader = new Loader();
var urlReq:URLRequest = new URLRequest("animPageExt.swf");

swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadComplete);
swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
swfLoader.load(urlReq);

function swfLoadComplete(evt:Event):void
{
var videoloader:Loader = Loader(evt.target.loader);
addChild(videoloader.content);
swfLoader.removeEventListener(Event.COMPLETE, swfLoadComplete);
}

function swfLoadError(evt:IOErrorEvent):void
{
trace("Unable to load swf ");
swfLoader.removeEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
}

The player that I'm using is JCPlayer which I downloaded from www(dot)jcplayer(dot)com.

Thanks
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

I think I understand what you have going on, but I'm a little hazy on how you've actually implemented what your describing.

However, this little background might help you get it all sorted. Basically there are two types of content being loaded into flash. The flv and other swf files and the way flash treats their paths are completely different.

When you load an external swf into flash its treated as if it REPLACES the target movieclip, but it retains the target clips instance name. So if you have a target clip called "swftarget" and a new swf being loaded called "myswf.swf", once the load is complete you would refer to the clip in the code as swftarget.someActionHere();

An flv file is almost exactly the same it just doesn't replace your player. Its loaded INTO a player clip in the same way that you load a DVD into your DVD Player. Instead of saying "The Incredibles".stop() you would say DVD Player.stop();

Make sense?

Now I'm assuming your problem is that your loading your flv player into a target just like any other section which would mean that you need to target the replaced container mc and then target the player within that container. So you need something like swftarget.DVDPlayer.stop();

Obviously you'll need to find the correct names for objects based on your code.

There may also be a catch with using a prebuilt video player, in that you may not have a name or methods exposed to your actionscript. It could actually all be baked into the player itself. In which case you might be out of luck and your only option would be to completely delete the flv player each time you hide it.

Think of it like this: going to another page is like walking out of the room that contains the DVD Player from above. Even though you can't see it the video is still playing (but you can probably hear it) You could hit pause on the remote when you leave the room or if for some reason that doesn't work you would need to find a way to make the DVD Player actually cease to exist or its default action will be to play the movie until its complete.

I'm sorry I can't be more help but hopefully that gets you enough theory about how its all working to find a fix for your problem.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.