PDA

View Full Version : Communicate between flvPlayer and another swf-file


permort
09-24-2009, 11:28 AM
I canīt figure out how to communicate between these two .swf-files.
The first file, "coordinates.swf" is tracking the coordinates and play/pause my flv-videos. The second file, "flvPLayer.swf" is playing the flv-file.

What I want to do is to play/pause the video when the pano is between spesific coordinates.

My question is:How do I call the "playVideo" function in "flvPlayer.swf" from "coordinates.swf"?

Here is my code so far. This is from "coordinates.swf":
if (coordinate < -95 && coordinate > -170) {
//Here I want to call the "playVideo" function in "flvPlayer.swf"

} else {
//Here I want to call the "pauseVideo" function in "flvPlayer.swf"
}

This is some code from "flvPlayer.swf". I have paused at frame 1 so itīs not starting when loaded:

function connectStream():void {

stream = new NetStream(connection);
stream.client = this;
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

video = new Video(375, 225);
vid.addChild(video);
video.attachNetStream(stream);
stream.play(file);
stream.seek(1);
stream.pause();


}
function playVideo() {
stream.resume();
}
function pauseVideo() {
stream.pause();
}

allSaints
09-24-2009, 11:36 AM
May I suggest checking up the commander.swf plugin. It may be capable of handling what you want to achieve.

Tommy

permort
09-24-2009, 01:23 PM
Thankīs for your reply, but I canīt see how to do this with your plug-in.
I guess I have to use "commandIn" and "commandOut" but all the examples in the xml-file links to global-functions in FPP XML-file.

In one global function, you use "stopVideo()". Where is that function defined?

allSaints
09-24-2009, 01:43 PM
Thanks for spotting an error - stopVideo() should be stopTgrLou().

And these are FPP commands, yes. And with FPP commands you can easily handle your plugins...

permort
09-25-2009, 09:41 AM
ok, I found some kind of solution, but itīs not optimal. I appreciate other ideas, please ;)

What I did was to call two FPP commands from "coordinates.swf":
if (coordinate < -95 && coordinate > -170) {

if (spotObject3.visible == 0) {
spotObject3.visible=1;
hotspots.execute("global.start_video");
}
} else {
hotspots.execute("global.stop_video");
}


My xml-file:

//Global parameter
start_video="spot.visible=1; spot.url=files/flvplayer_toril.swf;"
stop_video="spot.visible=0; spot.url=;"

//Hotspot
<box id="spot" file="movies/video.flv" scaleable="0" smoothing="0" pan="-123.00" refreshRate="20" segmentsX="10" segmentsY="10" />


The problem with this solution are two things:
1. The video.flv file starts streaming a new stream each time the command "start_video" is called. It seems like "stop_video" command donīt stop the stream. This is not good because it takes a lot of bandwidth. I want to use the same file from cache over and over again, so the video only loads one time.

2. I want to pause the stream before itīs starting. If I do that, the stream can load in the background and start to play at once when the coordinates are right.

The best solution for me is to be able to call a function in flvPlayer.swf from the xml-file. Please help!!

allSaints
09-25-2009, 11:14 AM
If your flvPlayer.swf is a hotspot plugin, you can have a timer checking the value of a hotspot parameter, for example "cmd", and as soon as that parameter is set to a specific value, you can execute your function.

If that is not good enough, you have to use the LocalConnection API or the ExternalInterface API.

permort
09-25-2009, 12:09 PM
Thanks a lot!! Great idea
Itīs now working :)

What I did was to make a timer function in "flvPlayer.swf" to check the visible status of the hotspot.