共用方式為


Using the invokeURLs Property in a Web Page Displayed by Firefox

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

Some media files contain embedded URLs for which Windows Media Player displays webpages in a Web browser window or frame as the media file plays. In Windows Internet Explorer, you can use the Settings.invokeURLs property to specify whether pages are displayed for embedded URLs, and you can use the Settings.defaultFrame property to specify a frame for displaying such pages.

In Firefox, some workarounds are required to set the invokeURLs property and to specify a frame for displaying pages for embedded URLs.

Setting the invokeURLs property

The default value of the Settings.invokeURLs property is true, so if you want the value to be false, you must set it explicitly. In Internet Explorer, you can set invokeURLs to false in a PARAM element inside the Player control's OBJECT element.

The Firefox plug-in does not support setting the invokeURLs property in a PARAM element.

You can work around this limitation by setting the invokeURLs property in script. The following code shows how to set the invokeURLs property to false in a webpage that can be displayed by both Internet Explorer and Firefox.

<HTML>
  <BODY OnLoad="Initialize()">

    <SCRIPT type="text/javascript">

      document.write('<OBJECT id="Player"'); 

      if(-1 != navigator.userAgent.indexOf("MSIE"))
      {               
        document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');       
      }
      else if(-1 != navigator.userAgent.indexOf("Firefox"))
      {      
        document.write(' type="application/x-ms-wmp"');        
      }  

      document.write(' width=300 height=200>');
      document.write('<PARAM name="autoStart" value="false"/>');
      document.write('<PARAM name="url" value="c:\\MediaFiles\\Glass.wmv"/>');
      document.write('</OBJECT>'); 
      
    </SCRIPT>

    <SCRIPT>
      function Initialize()
      {
        Player.settings.invokeURLs = false;
        Player.controls.play();
      }
    </SCRIPT>

  </BODY>
</HTML>

Displaying webpages in a frame

A media file can contain URLs that display webpages in a browser window or frame as the media file is played. In Internet Explorer, you can use the Settings.defaultFrame property to specify the frame in which those pages are displayed. If you do not set the defaultFrame property, URLs are displayed in a separate window of the default browser. However, the Firefox plug-in does not support the Settings.defaultFrame property. To work around this limitation, set the Settings.invokeURLs property to false and write a ScriptCommand event handler that sets the location of the target frame. The following example, which works in Internet Explorer and Firefox, illustrates this technique. Assume that the webpage shown in the example is in frames[0] and you want the URL's page to be displayed in frames[1].

<HTML>
  <BODY OnLoad="Initialize()">

    <SCRIPT type="text/javascript">

      document.write('<OBJECT id="Player"'); 

      if(-1 != navigator.userAgent.indexOf("MSIE"))
      {               
        document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');       
      }
      else if(-1 != navigator.userAgent.indexOf("Firefox"))
      {      
        document.write(' type="application/x-ms-wmp"');        
      }  

      document.write(' width=300 height=200>');
      document.write('<PARAM name="autoStart" value="false"/>');
      document.write('<PARAM name="url" value="c:\\MediaFiles\\Glass.wmv"/>');
      document.write('</OBJECT>'); 
      
    </SCRIPT>

    <SCRIPT>
      function Initialize()
      {
        Player.settings.invokeURLs = false;
        Player.controls.play();
      }
    </SCRIPT>

    <SCRIPT for="Player" event="ScriptCommand(scType, scParam)">
      if( scType == "URL" )
      {
        parent.frames[1].location = scParam;
      }
    </script>

  </BODY>
</HTML>

Using the Windows Media Player Control with Firefox