IWMPMedia::sourceURL 属性

[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]

sourceURL 属性获取媒体项的 URL。

此属性为只读。

语法

public System.String sourceURL {get;}

Public ReadOnly Property sourceURL As System.String

属性值

作为源 URL 的 System.String

示例

以下示例使用 sourceURL 检索“所有音乐”播放列表中第一个媒体项的 URL;然后将媒体项的 URL 分配给播放器对象 URL 属性。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

// Get an interface to the All Music Playlist. 
WMPLib.IWMPPlaylist pl = player.playlistCollection.getByName("All Music").Item(0);

// Store a WMPLib.IWMPMedia3 interface to the first media item in the playlist. 
WMPLib.IWMPMedia3 media = (WMPLib.IWMPMedia3)pl.get_Item(0);

// Change the URL property of the player to the URL of the media item.
player.URL = media.sourceURL;

// Play the media item.
player.Ctlcontrols.play();

' Get an interface to the All Music Playlist. 
Dim pl As WMPLib.IWMPPlaylist = player.playlistCollection.getByName("All Music").Item(0)

' Store a WMPLib.IWMPMedia3 interface to the first media item in the playlist. 
Dim media As WMPLib.IWMPMedia3 = pl.Item(0)

' Change the URL property of the player to the URL of the media item.
player.URL = Media.sourceURL

' Play the media item.
player.Ctlcontrols.play()

要求

要求
版本
Windows 媒体播放器 9 系列或更高版本
命名空间
WMPLib
程序集
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

另请参阅

IWMPMedia 接口 (VB 和 C#)