Training
Certifications
Books
Special Offers
Community




 
Microsoft® Windows Media™ Player for Windows® XP Handbook
Author Seth McEvoy
Pages 384
Disk 1 Companion CD(s)
Level All Levels
Published 10/31/2001
ISBN 9780735614550
Price $29.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Index
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 


Chapter 12: Creating Custom Media Content continued


Using Markers

A marker is a pointer to a specific location inside an audio or video file. Each marker has a name and a position. The position is a measure of time, in seconds, from the beginning of the file. A file can have any number of markers, but it can have only one marker at any given time position.

Inserting Markers

You can insert markers into a file with the Windows Media Advanced Script Indexer tool, which is included on the companion CD of this book. It is also part of the Windows Media Resource Kit, which can be downloaded from the Windows Media Web site at:

http://www.microsoft.com/windowsmedia/

Figure 12.1 shows the Advanced Script Indexer displaying three markers in a file named jeanne.wma. This file is included with the Windows Media Player SDK.

Click to view graphic
Click to view graphic

Figure 12.1  Advanced Script Indexer displaying a file with three markers.

Marker Names

The three markers in jeanne.wma are named marker1, marker2, and marker3. They could have any names as long as each name is different. An application can listen for a marker name and respond when the marker is encountered in the specified file.

Marker Times

The file jeanne.wma has a duration of 56.1 seconds. Markers are placed at the following points in the file:

  • marker1: 0.0 seconds (the start of the file)
  • marker2: 19.0 seconds
  • marker3: 43.0 seconds

In this file, the markers are used to mark the opening, middle, and closing thematic portions of the music. But markers could be used for many different reasons. For example, you might want to divide a movie into scenes and allow users to switch to any scene they want at any time. Many DVD players allow this, making it possible for users to go back to named scenes. Moving to a specific position in a file is called seeking.

Using Markers with the Player

Windows Media Player can work with files that have markers embedded in them. When you choose File Markers from the View menu, you are presented with a list of the named markers in the currently playing file.

Figure 12.2 shows the Player when it is ready for you to select a position in the file by choosing a marker. The thumb of the seek bar is on the left side, indicating that the song has just started.

Click to view graphic
Click to view graphic

Figure 12.2  Getting ready to seek to a new position with a marker.

When the third marker, marker3, is chosen, the Player moves the file position to 43 seconds into the song. Figure 12.3 shows the Player after the position has moved to the third marker.

Click to view graphic
Click to view graphic

Figure 12.3  Position of the third marker in the file.

Using Markers in Scripts

These methods and properties are used by JScript to control a file with markers:

markerCount

You can use this property of the Media object to determine the number of markers in a file.

getMarkerName

This method of the Media object will give you the name of an indexed marker. For example, you could get the name of the third marker with getMarkerName(3).

getMarkerTime

This method of the Media object gives the time of an indexed marker in seconds. For example, you can get the time of the second marker with getMarkerTime(2).

currentMarker

You can use this method of the Controls object to seek to the position of the indexed marker. For example, to seek to the position of the first marker in a file, you would write to currentMarker(1). You can also use currentMarker to read the position of the current marker. The current marker duration extends from the position of the last marker encountered to just before the next marker.

The following JScript code shows how to use markers in script. The name of the Player object is Player1 and the function GoMarker is called with the parameter of mymark, which is the marker number you want to seek to. This script is for use in a Web page. If you were using the script in a skin, the object name would be player.

function GoMarker (mymark)

{

Player1.controls.currentMarker = mymark;

MyText1.value = Player1.currentMedia.getMarkerName(mymark);

MyText2.value = Player1.currentMedia.getMarkerTime(mymark);

MyText3.value = Player1.currentMedia.markerCount;

}

The function reads a marker number and uses it to seek to the position of the numbered marker in a file. Then the marker name, marker time, and total number of markers in the file are copied and displayed in individual text boxes.

For more information about markers, see the Windows Media Player SDK.


Previous   |  Table of Contents   |   Next



Last Updated: October 12, 2001
Top of Page