AxWindowsMediaPlayer.URL 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 URL property gets or sets the name of the media item to play.

Syntax

public System.String URL {get; set;}

Public Property URL As System.String

Property value

A System.String that is the URL of the media item.

Remarks

This property can only be set to a URL in a security zone that is the same or is less restrictive than the security zone of the calling program or webpage.

Applications that open media items from behind a firewall will have better performance if the address is specified using the domain name server (DNS) name instead of the IP address.

Do not call this method from event handler code. Calling URL from an event handler may yield unexpected results.

Examples

The following example allows the user to specify a media file by entering a file path in a text box. When a button is clicked, the URL property is set to the specified file and the file is played. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

private void openMedia_Click(object sender, System.EventArgs e)
{
    // Set the URL property to the file path obtained from the text box. 
    player.URL = inputURL.Text;

    // Play the media file. 
    player.Ctlcontrols.play();
}

Public Sub openMedia_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles openMedia.Click

    ' Set the URL property to the file path obtained from the text box. 
    player.URL = inputURL.Text

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

End Sub

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#)