Windows Media Player 11 SDK IWMPMedia.imageSourceWidth (VB and C#)
Previous | Next |
IWMPMedia.imageSourceWidth (VB and C#)
The imageSourceWidth property gets the width of the current media item in pixels.
[Visual Basic] ReadOnly Property imageSourceWidth As Integer [C#] int imageSourceWidth {get;}
Property Value
A System.Int32 that is the width of the media item.
Remarks
If the media item is not the current one, this property returns zero.
Before using this property, you must have read access to the library. For more information, see Library Access.
Example Code
The following example uses imageSourceWidth to display the image size, in pixels, of the current media item in a text box. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.
[Visual Basic]
' 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
FakePre-2129616d1b2a4dac868112145a2b9d18-d129a3f89526433bbae4c63fd36c64ee
// 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()); } } }
Requirements
Version: Windows Media Player 9 Series or later
Namespace: WMPLib
Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)
See Also
Previous | Next |