Controls.playItem method

[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.]

The playItem method plays the specified media item.

Syntax

Controls.playItem(
  theMediaItem
)

Parameters

theMediaItem [in]

Media object to be played.

Return value

This method does not return a value.

Remarks

The media item will be loaded and played automatically, regardless of the value of the Settings.autoStart property. To load an item without playing it automatically, set Settings.autoStart to false and assign a value to Player.URL, after which play can be called to start playing the item.

Note

playItem works only with items in currentPlaylist. Calling playItem with a reference to a saved media item is not supported.

Examples

The following JScript example uses playItem to play a media item from the current playlist. The item to play is chosen based upon its position in the playlist. The Player object was created with ID = "Player".

// Declare a variable to hold the position of the media item 
// in the current playlist. An arbitrary value is supplied here.
var index = 3

// Retrieve the media item at the fourth position in the current playlist.
var media = Player.currentPlaylist.item(index);

// Play the media item.
Player.controls.playItem(media);

Requirements

Requirement Value
Version
Windows Media Player version 7.0 or later.
DLL
Wmp.dll

See also

Controls Object

Playlist.item