IWMPNetwork::downloadProgress property
[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
The downloadProgress property gets the percentage of downloading completed.
Syntax
public System.Int32 downloadProgress {get; set;}
Public ReadOnly Property downloadProgress As System.Int32
Property value
A System.Int32 that is the download progress expressed as a percentage.
Remarks
When the Windows Media Player control is connected to a digital media file that can be played and downloaded at the same time, the downloadProgress property gets the percentage of the total file that has been downloaded. This feature is currently supported only for digital media files downloaded from web servers. A file of any of the following formats can be downloaded and played simultaneously:
- Advanced Systems Format (ASF)
- Windows Media Audio (WMA)
- Windows Media Video (WMV)
- MP3
- MPEG
- WAV
In addition, some AVI files can be downloaded and played simultaneously.
Use the AxWindowsMediaPlayer._WMPOCXEvents_BufferingEvent to determine when buffering starts or stops.
Examples
The following code example uses downloadProgress to display the percentage of downloading completed. The information is displayed in a label, in response to the Buffering Event. The example uses a timer with a 1-second interval to update the display. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named 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
Requirements
Requirement | Value |
---|---|
Version |
Windows Media Player 9 Series or later |
Namespace |
WMPLib |
Assembly |
|