IWMPMedia :: imageSourceWidth, propriété

La propriété imageSourceWidth obtient la largeur de l’élément multimédia actuel en pixels.

Cette propriété est en lecture seule.

Syntaxe

public System.Int32 imageSourceWidth {get;}

Public ReadOnly Property imageSourceWidth As System.Int32

Valeur de la propriété

System. Int32 qui correspond à la largeur de l’élément multimédia.

Notes

Si l’élément multimédia n’est pas celui en cours, cette propriété retourne la valeur zéro.

Avant d’utiliser cette propriété, vous devez disposer d’un accès en lecture à la bibliothèque. Pour plus d’informations, consultez accès à la bibliothèque.

Exemples

L’exemple suivant utilise imageSourceWidth pour afficher la taille de l’image, en pixels, de l’élément multimédia actuel dans une zone de texte. L’objet AxWMPLib. AxWindowsMediaPlayer est représenté par la variable 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

            &#39; Display the image size information.
            videoSize.Text = (Width.ToString() + &quot; x &quot; + Height.ToString())

        End If

    End If

End Sub

Spécifications

Condition requise Valeur
Version
Lecteur Windows Media série 9 ou version ultérieure
Espace de noms
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

Voir aussi

Interface IWMPMedia (VB et C#)