Silverlight MediaElement Progress

I am trying to create a custom media player in Silverlight. I am working on a progress bar. I want the progress bar to display the current current load, as well as the current position MediaElementduring playback.

To do this, I have a progress bar to display the download progress and an overlay slider to display the current position.

I set the value for both as a percentage of 100.

For instance:

ProgressBar.Value = MediaElement.DownloadProgress;
Slider.Value = (MediaElement.Position.TotalMilliseconds) / (MediaElement.NaturalDuration.TimeSpan.TotalMilliseconds);

The problem is that Slider.Value is getting bigger than ProgressBar.Value. How is this possible? How can I play a video in a more distant position than what was uploaded?

Any tips on how to sync them correctly?

Thank.

+3
1

, , . , , 300- , , , 60 , , 30 150 .

"", , , . , , .

Edit

, ?

, , .

Slider.Value = Math.Min(mediaelement.Position.TotalMilliseconds / mediaelement.NaturalDuration.TimeSpan.TotalMilliseconds, mediaelement.downloadprogress);
+4

Source: https://habr.com/ru/post/1753770/


All Articles