0

I have embedded a single swf three times named as video.swf.

The swfs names are video1 , video2 and video3.

If I play a swf, I wants to get the currently playing swf's name?

Is it possible ?

I'm using javascript for communication.

8
  • Your question is a tiny bit vague: first you state that it's about communication between SWFs, but then you state that you want to get currently playing SWFs name. Can you please clarify? Also, what kind of name are you referring to? SWF file name? Cheers. Commented Aug 10, 2011 at 13:00
  • Not really, but I'll give you a big fat answer, and we can dance from there. Commented Aug 10, 2011 at 13:09
  • @Benny Geo Are you able to get me now?* Commented Aug 10, 2011 at 13:10
  • wts that? you can say... Commented Aug 10, 2011 at 13:10
  • @Taurayi : hi... What you mean? Commented Aug 10, 2011 at 13:11

2 Answers 2

1

I had to do something very similar for work on a project for Swatch/MTV (having multiple embedded players on a page and playing only one clip at a time (playing a different clip, would pause others, etc.) e.g.

var vids = ['video/file/72066f40bfcaea46e10460585b4e4bcb.mp4','video/file/3d5db6b87f9cdacb016c9c55afed1e08.mp4','video/file/c18b04a1a548cbf20609de70a106d7cc.mp4','video/file/4568a11f3f6a7ff467a85fefe2ac08e6.mp4','video/file/b91081d37a81692194c0e34580958c51.mp4'];         for(var i = 0 ; i < vids.length; i++){
                var flashvars = {};
                flashvars.video_url = 'http://www.swatchmtvplayground.com/'+vids[i];
                flashvars.video_id = i;
                flashvars.locale = "gb";
                flashvars.skin = 'upperBackground:0xf8c3c4,lowerBackground:0xe2e2e2,generalControls:0x000000,slider:0xb58f8f,progress:0xe2e2e2';
                var params = {};
                var attributes = {};
                attributes.id = "mediaplayer"+i;
                so = swfobject.embedSWF("http://www.swatchmtvplayground.com/flash/mediaplayer/mediaplayer.swf", "mediaplayer"+i, "578", "345", "10.0.0", false, flashvars, params, attributes);
            }
            function pauseAllPlayers(exceptThisOne){
                for(var i = 0 ; i < vids.length ; i++) if(exceptThisOne != "mediaplayer"+i) document.getElementById("mediaplayer"+i).pause();
            }

to get the id I've used a neat little trick I didn't previously know about (executing JS created with actionscript) using Zeh Fernando's excellent guide: Getting the SWF’s HTML object/embed id from within the Flash movie itself

HTH

Sign up to request clarification or add additional context in comments.

Comments

1

If you're using the same swf file three times you'd have to pass in a flash var to let the swf know which instance it is (video1, video2, or video3). Then when a video.swf instance starts playing use AS3's ExternalInterface to call JavaScript and mark that swf instance as the one currently playing.

Using SWFObject to embed the swfs in the page you can set the flashvars in JavaScript like this:

var flashvars1 = {
    name: "video1",
};

swfobject.embedSWF("video1.swf", "flashContent1", "640", "480", "10.0.0", false, flashvars1, {}, {});

var flashvars2 = {
    name: "video2",
};

swfobject.embedSWF("video2.swf", "flashContent2", "640", "480", "10.0.0", false, flashvars2, {}, {});

var flashvars3 = {
    name: "video3",
};

swfobject.embedSWF("video3.swf", "flashContent3", "640", "480", "10.0.0", false, flashvars3, {}, {});

Within each swf you'll now have a 'name' var that can be accessed through LoaderInfo:

var name:String = LoaderInfo(this.root.loaderInfo).parameters.name;

And you call ExternalInterface from Flash like so:

ExternalInterface.call( "videoPlaying", name );

This would call a JavaScript function called 'videoPlaying' with the name as the argument:

function videoPlaying(name) {
    // do something with the name arg
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.