Share via


Proprietà IWMPMedia::imageSourceWidth

[La funzionalità associata a questa pagina, Lettore multimediale Windows SDK, è una funzionalità legacy. È stato sostituito da MediaPlayer. MediaPlayer è stato ottimizzato per Windows 10 e Windows 11. Microsoft consiglia vivamente che il nuovo codice usi MediaPlayer invece di Lettore multimediale Windows SDK, quando possibile. Microsoft suggerisce che il codice esistente che usa le API legacy venga riscritto per usare le nuove API, se possibile.

La proprietà imageSourceWidth ottiene la larghezza dell'elemento multimediale corrente in pixel.

Questa proprietà è di sola lettura.

Sintassi

public System.Int32 imageSourceWidth {get;}

Public ReadOnly Property imageSourceWidth As System.Int32

Valore proprietà

Oggetto System.Int32 che corrisponde alla larghezza dell'elemento multimediale.

Commenti

Se l'elemento multimediale non è quello corrente, questa proprietà restituisce zero.

Prima di usare questa proprietà, è necessario disporre dell'accesso in lettura alla libreria. Per altre informazioni, vedere Accesso alla libreria.

Esempio

L'esempio seguente usa imageSourceWidth per visualizzare le dimensioni dell'immagine, in pixel, dell'elemento multimediale corrente in una casella di testo. L'oggetto AxWMPLib.AxWindowsMediaPlayer è rappresentato dalla variabile denominata 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

Requisiti

Requisito Valore
Versione
Lettore multimediale Windows serie 9 o successive
Spazio dei nomi
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

Vedi anche

Interfaccia IWMPMedia (VB e C#)