controlling mediaplayer source through javascript in Firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xhunter
    New Member
    • May 2007
    • 42

    controlling mediaplayer source through javascript in Firefox

    ok here is my problem,

    I am trying to change the source file of the mediplayer using javascript, my script works perfectly in "Internet Explorer", but no matter what I do, it doesn't work in Firefox

    here is my player :
    [HTML]
    <OBJECT classid=CLSID:2 2D6F312-B0F6-11D0-94AB-0080C74C7E95
    height=276 id=mediaPlayer type=applicatio n/x-oleobject width=320
    standby="Loadin g Video...">
    <embed
    id="mediaPlayer "
    type="applicati on/x-mplayer2"
    pluginspage="ht tp://www.microsoft.c om/windows/windowsmedia/download/"
    src="dummy.asx"
    name="mediaPlay er"
    width="320"
    height="276"
    autostart="0"
    showcontrols="0 " >
    </embed>
    </OBJECT>
    [/HTML]

    and here is the javascript function called to change the source:


    Code:
    <script language="javascript">  
    filename = 'somename.wmv';
    movieName = 'mediaPlayer';
    if (window.document[movieName]) {window.document[movieName].fileName = filename;}
    if (navigator.appName.indexOf("Microsoft Internet")==-1){if (document.embeds && document.embeds[movieName]) document.embeds[movieName].fileName = filename; }
    else {document.getElementById(movieName).fileName = filename;}
    </script>
    any help is really appreciated.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Firstly, you can't have two elements with the same ID.

    Secondly, FileName should be a param object within the object tags.

    Comment

    • xhunter
      New Member
      • May 2007
      • 42

      #3
      Originally posted by acoder
      Firstly, you can't have two elements with the same ID.

      Secondly, FileName should be a param object within the object tags.
      thanx.

      as I mentioned, it works perfectly in IE and so param FileName is not really needed.

      I tried giving a different name for object and embed, but didn't work again.

      it just doesn't work, without returning any errors (firebug).

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by xhunter
        as I mentioned, it works perfectly in IE and so param FileName is not really needed.
        Just because it works in IE doesn't necessarily mean it's correct.
        Originally posted by xhunter
        I tried giving a different name for object and embed, but didn't work again.
        The ID needs to be different. You can have two objects with the same name (if need be).

        Does this work without using JavaScript, i.e. can you get this to work with HTML only? If not, check that you have the correct plugins.

        Comment

        • xhunter
          New Member
          • May 2007
          • 42

          #5
          it works perfectly in IE with or without javascript (with a source in param),

          it works in FF when a real src has been specified,

          the javascript is supposed to change that source (with no source specified at first),

          the reason that I said that param is not needed is as i think that part of embedding is for IE and in my case that I am not putting any src for initial load and load movies through js it works fine without it, and FF part is inside <embed> which has a src with a dummy source,

          The Player works fine,
          the only problem is javascript can't change the source in FF,

          if the JS script is wrong, I am expecting some errors in FF (firebug), but no errors are returned, meaning the execution was a accepted but I can't get any effect.

          Comment

          • xhunter
            New Member
            • May 2007
            • 42

            #6
            There is another strange thing,

            it doesn't really matter to me, but I thought maybe that is sort of related.

            This script of mine, in IE , only works with this classid :
            "22D6F312-B0F6-11D0-94AB-0080C74C7E95"
            which is for WMP6.4

            if set to any other calssids:
            WMP7-9-10:6BF52A52-394A-11D3-B153-00C04F79FAA6


            it doesn't work, not even in IE (no errors),

            I don't know why???

            Maybe FF plugin is loading WMP in >7 comptaible mode which causes this problem ???

            Then the problem is how to change the source if classid is for WMP > 7.

            Comment

            • xhunter
              New Member
              • May 2007
              • 42

              #7
              Ok,
              I managed to fix the classid problem by using "url" instead of "filename" that is

              document.mediaP layer.url = address;


              but yet it is not working in FF,

              I searched on internet and some suggested to use "src" as embed uses this param name, but no success with that either.

              I didn't find any working javascript manipulation of WMP for FireFox.

              if anybody knows how to do it, it is really appreciated,
              I am starting to bang my head to the wall and thinking maybe you cant use JS with WMP in FF.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Here's a reference for Windows Media Player. Hope it helps.

                Comment

                Working...