Share via


Windows Media Player 11 SDK IWMPMedia.sourceURL (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPMedia.sourceURL (VB and C#)

The sourceURL property gets the URL of the media item.

[Visual Basic]
ReadOnly Property sourceURL As String

[C#]
string sourceURL {get;}

Property Value

A System.String that is the source URL.

Example Code

The following example uses sourceURL to retrieve the URL of the first media item in the "All Music" playlist; the URL of the media item is then assigned to the player object URL property. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

[Visual Basic]
' 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()

FakePre-8f672f22aeb44561aee0ac75dbeea70d-886c487d30a54423ac61ef1ff4ad6223

// 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();

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)

See Also

Previous Next