Proprietà IWMPNetwork::d ownloadProgress

[La funzionalità associata a questa pagina, Lettore multimediale Windows SDK, è una funzionalità legacy. È stata sostituita da MediaPlayer. MediaPlayer è stato ottimizzato per Windows 10 e Windows 11. Microsoft consiglia vivamente che il nuovo codice usi MediaPlayer anziché 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à downloadProgress ottiene la percentuale di download completata.

Sintassi

public System.Int32 downloadProgress {get; set;}

Public ReadOnly Property downloadProgress As System.Int32

Valore proprietà

Oggetto System.Int32 che rappresenta lo stato di avanzamento del download espresso come percentuale.

Commenti

Quando il controllo Lettore multimediale Windows è connesso a un file multimediale digitale che può essere riprodotto e scaricato contemporaneamente, la proprietà downloadProgress ottiene la percentuale del file totale scaricato. Questa funzionalità è attualmente supportata solo per i file multimediali digitali scaricati dai server Web. Un file di uno dei formati seguenti può essere scaricato e riprodotto contemporaneamente:

  • Advanced Systems Format (ASF)
  • Windows Media Audio (WMA)
  • Windows Media Video (WMV)
  • MP3
  • MPEG
  • WAV

Inoltre, alcuni file AVI possono essere scaricati e riprodotti simultaneamente.

Usare il AxWindowsMediaPlayer._WMPOCXEvents_BufferingEvent per determinare quando il buffer viene avviato o arrestato.

Esempio

Nell'esempio di codice seguente viene usato downloadProgress per visualizzare la percentuale di download completata. Le informazioni vengono visualizzate in un'etichetta, in risposta all'evento buffering . Nell'esempio viene usato un timer con un intervallo di 1 secondo per aggiornare la visualizzazione. L'oggetto AxWMPLib.AxWindowsMediaPlayer è rappresentato dalla variabile denominata 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

Requisiti

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

Vedi anche

Evento AxWindowsMediaPlayer.Buffering (VB e C#)

Interfaccia IWMPNetwork (VB e C#)