Propriété IWMPMedia::imageSourceWidth
[La fonctionnalité associée à cette page, Lecteur multimédia Windows SDK, est une fonctionnalité héritée. Il a été remplacé par MediaPlayer. MediaPlayer a été optimisé pour Windows 10 et Windows 11. Microsoft recommande vivement que le nouveau code utilise MediaPlayer au lieu de Lecteur multimédia Windows SDK, lorsque cela est possible. Microsoft suggère que le code existant qui utilise les API héritées soit réécrit pour utiliser les nouvelles API si possible.]
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 l’élément actuel, cette propriété retourne 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 nommée 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
Configuration requise
Condition requise | Valeur |
---|---|
Version |
série Lecteur multimédia Windows 9 ou ultérieure |
Espace de noms |
WMPLib |
Assembly |
|
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour