次の方法で共有


AxWindowsMediaPlayer.currentMedia property

[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 currentMedia property gets or sets the IWMPMedia interface that corresponds to the current media item.

Syntax

public IWMPMedia currentMedia {get; set;}

Public Property currentMedia As IWMPMedia

Property value

The WMPLib.IWMPMedia interface that provides access to the current media item.

Remarks

If the AxWindowsMediaPlayer.settings.autoStart property is true, playback begins automatically whenever you set currentMedia.

You can retrieve an IWMPMedia interface for a given media item through the IWMPPlaylist.Item property (the IWMPPlaylist.get_Item method in C#). To load a media item using a file name, set the URL property or use newMedia.

Examples

The following example retrieves the first media item in the library and uses the currentMedia property to set the retrieved media item as the current media item and display its name. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

// Get an interface to the first media item in the library. 
WMPLib.IWMPMedia3 firstMedia = (WMPLib.IWMPMedia3)player.mediaCollection.getAll().get_Item(0);

// Make the retrieved media item the current media item.
player.currentMedia = firstMedia;

// Display the name of the current media item.
currentMediaLabel.Text = ("Found first media item. Name = " + player.currentMedia.name);

' Get an interface to the first media item in the library. 
Dim firstMedia As WMPLib.IWMPMedia3 = player.mediaCollection.getAll().Item(0)

' Make the retrieved media item the current media item.
player.currentMedia = firstMedia

' Display the name of the current media item.
currentMediaLabel.Text = ("Found first media item. Name = " + player.currentMedia.name)

Requirements

Requirement Value
Version
Windows Media Player 9 Series or later
Namespace
AxWMPLib
Assembly
AxInterop.WMPLib.dll (AxInterop.WMPLib.dll.dll)

See also

AxWindowsMediaPlayer Object (VB and C#)

AxWindowsMediaPlayer.newMedia (VB and C#)

AxWindowsMediaPlayer.URL (VB and C#)

IWMPMedia Interface (VB and C#)

IWMPPlaylist.Item (VB and C#)

IWMPSettings.autoStart (VB and C#)