IWMPNetwork :: bufferingProgress, propriété

La propriété bufferingProgress obtient le pourcentage de la mise en mémoire tampon terminée.

Syntaxe

public System.Int32 bufferingProgress {get; set;}

Public ReadOnly Property bufferingProgress As System.Int32

Valeur de la propriété

System. Int32 qui correspond à la progression de la mise en mémoire tampon exprimée en pourcentage.

Notes

Chaque fois que la lecture est arrêtée et redémarrée, cette propriété est réinitialisée à zéro. Elle n’est pas réinitialisée si la lecture est suspendue.

La mise en mémoire tampon s’applique uniquement au contenu de diffusion en continu. Cette propriété obtient des informations valides uniquement au moment de l’exécution lorsque l’URL pour la lecture est définie à l’aide de la propriété AxWindowsMediaPlayer. URL .

Utilisez AxWindowsMediaPlayer. _ WMPOCXEvents _ BufferingEvent pour déterminer à quel moment la mise en mémoire tampon démarre ou s’arrête.

Exemples

L’exemple suivant utilise bufferingProgress pour afficher le pourcentage de mise en mémoire tampon effectuée 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 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 buffering progress in a timer event handler.
private void UpdateBufferingProgress(object sender, EventArgs e)
{
    bufferingProgressLabel.Text = ("Buffering progress: " + player.network.bufferingProgress + " 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 buffering progress in a timer event handler.
Public Sub UpdateBufferingProgress(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick

    bufferingProgressLabel.Text = ("Buffering progress: " + player.network.bufferingProgress + " percent complete")

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

AxWindowsMediaPlayer. URL (VB et C#)

événement AxWindowsMediaPlayer. buffering (VB et C#)

Interface IWMPNetwork (VB et C#)