Windows Media Player 11 SDK About the MediaCollection and Media Objects
Previous | Next |
About the MediaCollection and Media Objects
The MediaCollection and Media objects govern the media collection, which defines the locations of digital 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), use the following code:
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, this code gets the duration property of the current Media object:
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 of code could be used.
To get the duration of the currently playing media:
player.currentMedia.duration;
To get the duration of the current media in a playlist:
player.controls.currentItem.duration;
To get the duration of the third media item in a playlist:
player.currentPlaylist.item(2).duration;
To get the duration of the third media item in a "Jazz" genre:
player.mediaCollection.getByGenre("jazz").item(2).duration;
To get the duration of the third media item in the second playlist:
player.playlistCollection.getAll.item(1).item(2).duration;
See Also
Previous | Next |