plug-in javascript help!

Help
Geetz Romo
2005-02-01
2013-05-13
  • Geetz Romo

    Geetz Romo - 2005-02-01

    Folks,
    I've searched hi and low and have found a lot of talk about mplayerplug-in and javascript but have not found any javascript code that actually works.  I've attached the code I'm using that keeps giving me "player.play (or stop or whatever)" is not a function" errors.

    PLEASE post some code that actually sets up the embed, creates the function with appropriate targeting to the plugin and the code to call it.  I know it should be easy but it ain't working. 

    ------------- start my code here --------------------
    <object id="Player" width="320" height="240">
        <param name="Src" value="video/test.mov">
    <embed
        name="Player"
        ShowControls="false"    
        fullscreen="true"
        showlogo="false" 
        src="video/test.mov"
        width="320"
        height="240">
    </embed>
    </object>

    <script language="JavaScript">
    <!--
       function stopplayer ()   {
           document.Player.stop();
       }
    -->
    </script>
    <a href="javascript:stopplayer();">STOP</a>
    --------- end my code ------------------------------------

    I'm running: Fedora Core 3 and Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041111 Firefox/1.0

    Many thanks in advance,

    Geetz

     
    • Kevin DeKorte

      Kevin DeKorte - 2005-02-01

      <HTML>
      <HEAD>
      <TITLE>Simple Plug-in Test</TITLE>
      </HEAD>
      <BODY>

      <center>
      <h1> XPConnect Scriptable Sample Plug-in </h1>
      </center>

      This page contains a testcase which demonstrates the work of scriptable
      plug-in with Mozilla. This example plug-in has no native GUI and does not
      draw anything in the plugin window. Clicking on the button will result in calling
      native plugin method from JavaScript. Show Version will instruct the plug-in
      to retrieve the Mozilla user agent string and return it to JavaScript to show
      in the alert box.

      <br><br>

      <center>

      <embed onMediaComplete="NewFile();" type="application/x-mplayer2" width=500 height=400 autostart=0 filename="file:///home/kdekorte/Movies/duality.divx"><br>

      <script>
      var embed = document.embeds[0];

      function complete()
      {
        alert("Media Complete");
      }

      function Play()
      {
        embed.Play();
      }

      function CPlay()
      {
        embed.controls.play();
      }

      function CPause()
      {
        embed.controls.pause();
      }

      function CStop()
      {
        embed.controls.stop();
      }

      function Pause()
      {
        embed.Pause();
      }

      function DoPlay()
      {
        embed.DoPlay();
      }

      function DoPause()
      {
        embed.DoPause();
      }

      function Stop()
      {
        embed.Stop();
      }

      function Quit()
      {
        embed.quit();
      }

      function FastForward()
      {
        embed.FastForward();
      }

      function FastReverse()
      {
        embed.FastReverse();
      }

      function PlayState()
      {
         alert(embed.playState);
      }

      function OrigFile()
      {
          embed.filename = "09_Holiday.mp3";
          embed.play();
      }

      function NewFile()
      {
          embed.filename = "sexy.mpg";
          embed.Play();
      }

      function File()
      {
          alert(embed.filename);
      }

      function gTime()
      {
          alert(embed.getTime());
      }
      function gDuration()
      {
          alert(embed.getDuration());
      }
      function gPercent()
      {
          alert(embed.getPercent());
      }

      function FS()
      {
          embed.fullscreen = true;
      }

      function FSOff()
      {
          embed.fullscreen = false;
      }

      function ControlsOn()
      {
          embed.ShowControls = true;
      }

      function ControlsOff()
      {
          embed.ShowControls = false;
      }

      </script>

      <br>
      <form name="formname">
      <input type=button value="Play" onclick='Play()'>
      <input type=button value="ControlsPlay" onclick='CPlay()'>
      <input type=button value="ControlsPause" onclick='CPause()'>
      <input type=button value="ControlsStop" onclick='CStop()'>
      <input type=button value="DoPlay" onclick='DoPlay()'>
      <input type=button value="Pause" onclick='Pause()'>
      <input type=button value="DoPause" onclick='DoPause()'>
      <input type=button value="Stop" onclick='Stop()'>
      <input type=button value="Quit" onclick='Quit()'>
      <br>
      <input type=button value="FF" onclick='FastForward()'>
      <input type=button value="Rew" onclick='FastReverse()'>
      <input type=button value="State" onclick='PlayState()'>
      <input type=button value="Orginal File" onclick='OrigFile()'>
      <input type=button value="New File" onclick='NewFile()'>
      <input type=button value="Filename" onclick='File()'>
      <input type=button value="Time" onclick='gTime()'>
      <input type=button value="Duration" onclick='gDuration()'>
      <input type=button value="Percent" onclick='gPercent()'>
      <input type=button value="FS" onclick='FS()'>
      <input type=button value="Window" onclick='FSOff()'>
      <input type=button value="Controls ON" onclick='ControlsOn()'>
      <input type=button value="Controls OFF" onclick='ControlsOff()'>

      </form>

      </center>

      </BODY>
      </HTML>

       
      • Peter Kyme

        Peter Kyme - 2005-02-03

        Is there currently anyway to setup a playlist via javascript, or if not that then specify another url to be loaded once the current movie has completed?

        I'm looking for a way to have a series of quicktime movies play back to back in a loop.

        Thanks in advance.

         
        • Kevin DeKorte

          Kevin DeKorte - 2005-02-03

          look at the onMediaComplete callback. You can have it load a new file when the first one is done. You can setup an array of filenames to play, and store what index is being played and on the MediaCallback load the next item in the array or you can create a playlist and pass that as the file to open.

          A simple playlist is just a list of urls
          playlist.html
          http://host/file1.wma
          http://host/file2.wma

          etc...

           
    • Geetz Romo

      Geetz Romo - 2005-02-02

      thank you for the script!  Works like a champ.
      One bit that seems to be absent is a way to seek to a particular spot in the video.  Does this functinality exist?

      Thanks again.

      Geetz

       
      • Kevin DeKorte

        Kevin DeKorte - 2005-02-02

        From the javascript.txt file in the source package

            Seek(value)
           
                    Seeks "value" seconds into the media

         

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks