3 Replies Latest reply on Jun 1, 2009 1:48 PM by C-Rock

    Controll activex media player with flash?

    DrBarber

      Hey, got another question for the experts... I have a swf and an activex media player on a page... the stream urls are in my flash movie and I would like to be able to choose which stream to play in the media player by selecting a button on the swf...

       

      this is where i am currently in detail... skip to the bottom if you would like the quick description

       

      In flash i am connecting to my webservice and picking up three arrays. One called "vu", one called "vc", and one called "vt".

      "vu" contains about 5-10 urls depending on the day... vu1, vu2, vu3, vu4, vu5, etc...

      "vc" contains the name of the company streaming... "vc1" is the source of "vu1" etc.

      "vt" contains the name of the actual stream

       

       

      function getVideoList(){ 

      var pen:PendingCall = ws.GetVideoList();

          pen.onResult = function(res){

          var i  = 0;

          nvid=res.nvid;

          for (i=0;i<nvid;i++){

            vu[i] = res.vid[i].url;   //databasecode

            vc[i] = res.vid[i].src;   //databasecode 

            vt[i]  = res.vid[i].trk;   //name

           }

        }

      }

       

       

      I then use localconnection to send vu[i], vc[i], and vt[i] to a second swf that I want to simply control what is played through a media player also on the same page

       

       

      var outgoing_lc = new LocalConnection();

      startbutton.onRelease = function() {

          outgoing_lc.send("videolist","thefunction", vu, vc, vt);};

       

       

      This second swf picks it up and displays the names (vt) in dynamic text fields (called vx1-20) located on top of buttons. The company streaming (vc) is displayed in another dynmaic text field at the top.

      var incoming_lc = new LocalConnection();

       

      incoming_lc.connect("videolist");

      incoming_lc.thefunction = function(param1, param2, param3) {

           var i = 0;

           for (i=0; i<=param1.length-1; i++) {

              vx[i].text = param1[i];       

              vu[i] = param2[i]; 

              vc[i] = param3[i];

           }

      };

       

      import flash.external.*;

      function SelectVideo(n){

           videosrc.text = vc[n];

           

           HOW DO I SEND vu[n] ????????

       

      Im lost at the point in which i want clicking on a button and firing "SelectVideo(n)" to send the url (vu[n]) to the activex media player on the same page and play... dont know how to do it...? Sounds like a simple concept having the two communicate but I have had no luck. ExternalInterface is something ive tried but i cant seem to get it right on the actionscript side and removed it from the above code....In Dreamweaver the name of the activex media player is "mediaPlayer" and if ExternalInterface allows you to talk in javascript i have this function there...

      <script language="Javascript">

       

      function setVideoUrl(a){

                document.getElementById("mediaPlayer").setURL = a;}

       

      </script>

       

      This is the code for the media player object.

       

      <object     classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" 

                     codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=,1,52,701"

                     type="application/x-oleobject" width="340" height="240"

                     standby="Loading Microsoft Windows Media Player components..."

                     id="mediaPlayer">

                <param name="url"   value="video10.png">

                <param name="uimode" value="none">

                <param name="stretchToFit" value="true">

                <param name="enableContextMenu" value="true">

                <embed type="application/x-mplayer2"

                          src="http://www.mysite.com/video10.png" width=340 height=240>

                </embed>

      </object>

       

      SOOOOOOO... again... my question is... what do i do to make pressing a button in a swf fire a function thats sends and plays the url of that stream in the activex media player on the same page?

        • 1. Re: Controll activex media player with flash?
          clbeech Level 3

          ok - i think i'm following along here... we'll see LOL

           

          privided that everything else is functioning and passing the values properly, you should be able to hit the JS method using ExternalInterface, so in the SelectVideo method try this:

           

          ExternalInterface.call("setVideoUrl", vu[n]);

          • 2. Re: Controll activex media player with flash?
            DrBarber Level 1

            ok so in flash i have this on my script layer...

            import flash.external.*;

            function setVideoURL(n){ExternalInterface.call("setVideoURL", vu[n]);}

             

            In dreamweaver i have this in js

            function setVideoUrl(n){

                      document.getElementById("mediaPlayer").URL = a;

             

            Is this what you mean?

            • 3. Re: Controll activex media player with flash?
              C-Rock Level 2

              Looks like you're on the right track. The easiest way I found to do that is search Google for Flash and Javascript and create a test flash file and html file. You should be able to make your javascript in your html page just simple launch a new window and go to yahoo or something. That's how you know you're communicating with the javascript function correclty. Then put it into what you're doing and if it doesn't work you know it's a problem from the javascript to the media player not Flash to javascript. That should help quite a bit.

               

              I was able to do this from as2 to a popup that held an as3 document and them communicated back and forth to build a screen shot and then saved it. So I'm sure passing a string to a media player is possible and fairly easy