Propriété IWMPNetwork::d ownloadProgress

[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é downloadProgress obtient le pourcentage de téléchargement terminé.

Syntaxe

public System.Int32 downloadProgress {get; set;}

Public ReadOnly Property downloadProgress As System.Int32

Valeur de la propriété

System.Int32 qui correspond à la progression du téléchargement exprimée en pourcentage.

Notes

Lorsque le contrôle Lecteur multimédia Windows est connecté à un fichier multimédia numérique qui peut être lu et téléchargé en même temps, la propriété downloadProgress obtient le pourcentage du fichier total téléchargé. Cette fonctionnalité est actuellement prise en charge uniquement pour les fichiers multimédias numériques téléchargés à partir de serveurs web. Un fichier de l’un des formats suivants peut être téléchargé et lu simultanément :

  • ASF (Advanced Systems Format)
  • Audio Windows Media (WMA)
  • Vidéo Windows Media (WMV)
  • MP3
  • MPEG
  • WAV

En outre, certains fichiers AVI peuvent être téléchargés et lus simultanément.

Utilisez le AxWindowsMediaPlayer._WMPOCXEvents_BufferingEvent pour déterminer quand la mise en mémoire tampon démarre ou s’arrête.

Exemples

L’exemple de code suivant utilise downloadProgress pour afficher le pourcentage de téléchargement terminé. Les informations sont affichées dans une étiquette, en réponse à l’événement de mise en mémoire tampon . L’exemple utilise un minuteur avec un intervalle de 1 seconde pour mettre à jour l’affichage. L’objet AxWMPLib.AxWindowsMediaPlayer est représenté par la variable nommée player.

// Add a delegate for the Buffering event.
player.Buffering += new AxWMPLib._WMPOCXEvents_BufferingEventHandler(player_Buffering);

// Create an event handler for the Buffering event.
private void player_Buffering(object sender, AxWMPLib._WMPOCXEvents_BufferingEvent e)
{
    // Determine whether buffering has started or stopped.
    if (e.start == true)
    {
        // Set the timer interval at one second (1000 miliseconds).
        timer.Interval = 1000;
        
        // Start the timer.
        timer.Start();
    }
    else
    {
        // Buffering is complete. Stop the timer.
        timer.Stop();
    }
}

// Update the download progress in a timer event handler.
private void UpdateDownloadProgress(object sender, EventArgs e)
{
    downloadProgressLabel.Text = ("Download progress: " + player.network.downloadProgress + " percent complete");
}

' Create an event handler for the Buffering event.
Public Sub player_Buffering(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_BufferingEvent) Handles player.Buffering

    ' Test whether packets may be arriving.
    Select Case e.newState

    ' If WMPPlayState is Stopped, Paused, ScanForward, ScanReverse, Waiting, MediaEnded
    ' or Transitioning then stop the timer. 
        Case 1
        Case 2
        Case 4
        Case 5
        Case 7
        Case 8
        Case 9
            timer.Stop()

        ' If WMPPlayState is Playing or Buffering then set the timer interval and start the timer.
        Case Else
            timer.Interval = 1000
            timer.Start()

    End Select

End Sub

' Update the download progress in a timer event handler.
Public Sub UpdateDownloadProgress(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick

    downloadProgressLabel.Text = ("Download progress: " + player.network.downloadProgress + " percent complete")

End Sub

Configuration requise

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

Voir aussi

Événement AxWindowsMediaPlayer.Buffering (VB et C#)

IWMPNetwork Interface (VB et C#)