Windows Media Player SDK banner art
PreviousNext

About the MediaCollection and Media Objects

This object governs the media collection, which defines the locations of media files that Windows Media Player can access. You get the MediaCollection object from the mediaCollection property of the Player object. The mediaCollection property returns the MediaCollection object. You can only access the properties of the MediaCollection object after you have created it. For example, to add a Media object (a song), type the following:

     player.mediacollection.add('laure.wma')

You have added the file laure.wma to the media collection.

You can get the current Media object by using the currentMedia property of the Player. For example, to get the duration property of the current Media object, type:

     myduration = player.currentmedia.duration

There are many ways to get a Media object so that you can access its properties. For example, if you want to access the duration property of the current media, each of the following lines could be used:

To get the duration of the currently playing media, type:

player.currentMedia.duration

To get the duration of the current media in a playlist, type:

player.controls.currentItem.duration

To get the duration of the third media item in a playlist, type:

player.currentPlaylist.item(2).duration

To get the duration of the third media item in a "Jazz" genre, type:

player.mediaCollection.getByGenre("jazz").item(2).duration

To get the duration of the third media item in the second playlist, type:

player.playlistCollection.getAll.item(1).item(2).duration 
PreviousNext


© 2000-2001 Microsoft Corporation. All rights reserved.