Share via


Windows Media Player 11 SDK Using Script to Control URL FlippingĀ 

Windows Media Player SDK banner art

Previous Next

Using Script to Control URL Flipping

When a user connects to a rich media stream while the stream is already in progress, it is possible for the streamed Web page to display before all the elements have arrived and been cached if Windows Media Player automatically invokes the URL. When this happens, the user sees a blank or incomplete Web page until the next set of data arrives in the cache.

You can avoid displaying a blank or incomplete Web page by invoking the URL using script instead of letting Windows Media Player do it automatically. That way, you can ignore the first URL flip and then invoke subsequent URLs by using script code.

Note This section assumes that you are streaming HTML using the Windows Media Encoder 9 Series SDK and that you have set the HTML stream to repeat.

First, you must create a frameset Web page to contain the frame with the embedded Player and the frame that displays the streaming HTML. Each of these two frames will display a separate Web page initially, so you will create a total of three Web pages. The following example code demonstrates the frameset Web page:

<HTML>
<HEAD>
</HEAD>

<FRAMESET cols = "350, *">
  <FRAME  name = "player" src = "embed_player.htm">
  <FRAME  name = "content" src = "blank.htm">

  <NOFRAMES>
  <BODY>

  <P>This page uses frames, but your browser doesn't support them.</P>

  </BODY>
  </NOFRAMES>

</FRAMESET>
</HTML>

The preceding Web page example incorporates two frames. The first frame displays in the left half of the browser window and displays the Web page named embed_player.htm. The following example code creates this Web page:

<HTML>
<HEAD>
</HEAD>
<BODY>

<!-- Embed Windows Media Player and disable the invokeURLs parameter -->
<OBJECT CLASSID = "CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" ID = "Player">
  <PARAM name = "URL"  value = "https://www.proseware.com/Media/video.wmv">
  <PARAM name = "invokeURLs"  value = "false">
</OBJECT>

<SCRIPT LANGUAGE = "JScript">
  var bFirstURL = true; // Global flag for first URL flip.
</SCRIPT>

<!-- Create an event handler for script commands. -->
<SCRIPT LANGUAGE = "JScript"  FOR = "Player" EVENT = "ScriptCommand(scType, scParam)">

  if("URL" == scType)
  {
    if ( bFirstURL == false )
    {
      // Show the next URL flip.
      parent.content.location = scParam;
    }
    else
    {
      bFirstURL = false; // Set the flag.
    }
  }

</SCRIPT>

</BODY>
</HTML>

The second frame in the frameset displays in the right half of the browser window and displays a Web page named "blank.htm". The following example code creates this Web page:

<HTML>
<HEAD>
</HEAD>
<BODY>

Loading...
</BODY>
</HTML>

When the frameset page loads in the browser, the left frame shows the embedded Player and the right frame shows the text "Loading..." to inform the user that more data is forthcoming. When the first URL script command arrives from the HTML stream, the event handler simply changes the value of the Boolean flag. When each subsequent URL script command arrives from the HTML stream, the script in the event handler loads the new URL into the frame named "content", and the complete Web page displays in the frame located in the right half of the browser window.

For more information about streaming HTML using Windows Media, see the Windows Media Encoder SDK.

See Also

Previous Next