AxWindowsMediaPlayer.URL 属性
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
URL 属性获取或设置要播放的媒体项的名称。
语法
public System.String URL {get; set;}
Public Property URL As System.String
属性值
作为媒体项 URL 的 System.String。
备注
此属性只能设置为与调用程序或网页的安全区域相同或限制较少的安全区域中的 URL。
如果使用域名服务器 (DNS) 名称而不是 IP 地址指定地址,则从防火墙后打开媒体项的应用程序将具有更好的性能。
请勿从事件处理程序代码调用此方法。 从事件处理程序调用 URL 可能会产生意外结果。
示例
以下示例允许用户通过在文本框中输入文件路径来指定媒体文件。 单击按钮时,URL 属性将设置为指定的文件并播放该文件。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 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
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
AxWMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈