IWMPMedia::imageSourceWidth 属性
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
imageSourceWidth 属性获取当前媒体项的宽度(以像素为单位)。
此属性为只读。
语法
public System.Int32 imageSourceWidth {get;}
Public ReadOnly Property imageSourceWidth As System.Int32
属性值
一个 System.Int32 ,表示媒体项的宽度。
备注
如果媒体项不是当前媒体项,则此属性返回零。
在使用此属性之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问。
示例
以下示例使用 imageSourceWidth 在文本框中显示当前媒体项的图像大小(以像素为单位)。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Create an event handler for the OpenStateChange event.
private void player_OpenStateChange(object sender, AxWMPLib._WMPOCXEvents_OpenStateChangeEvent e)
{
// Test whether the new media item is open.
if (e.newState == (int)WMPLib.WMPOpenState.wmposMediaOpen)
{
// Store the height and width of the new media item.
int height = player.currentMedia.imageSourceHeight;
int width = player.currentMedia.imageSourceWidth;
// Clear all the information in the text box.
videoSize.Clear();
// Test whether an image is visible.
if (height != 0 && width != 0)
{
// Display the image size information.
videoSize.Text = (width.ToString() + " x " + height.ToString());
}
}
}
' Create an event handler for the OpenStateChange event.
Public Sub player_OpenStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_OpenStateChangeEvent) Handles player.OpenStateChange
' Test whether the new media item is open.
If (e.newState = WMPLib.WMPOpenState.wmposMediaOpen) Then
' Store the height and width of the new media item.
Dim Height As Integer = player.currentMedia.imageSourceHeight
Dim Width As Integer = player.currentMedia.imageSourceWidth
' Clear all the information in the text box.
videoSize.Clear()
' Test whether an image is visible.
If (Height <> 0 And Width <> 0) Then
' Display the image size information.
videoSize.Text = (Width.ToString() + " x " + Height.ToString())
End If
End If
End Sub
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈