Silverlight MediaElement 双缓冲
我有一个 MediaElement,它在缓冲时显示一个简单的进度条。它在 BufferingProgressChanged 事件中显示或隐藏。代码见下文。
问题是 MediaElement 通常决定缓冲两次,导致进度条显示两次。这是为什么?有办法解决吗?
谢谢!
private void MediaElement_BufferingProgressChanged(object sender, RoutedEventArgs e)
{
if (MediaElement.CurrentState == MediaElementState.Buffering)
{
BufferProgressBar.Value = MediaElement.BufferingProgress;
BufferGrid.Visibility = System.Windows.Visibility.Visible;
}
else
{
BufferGrid.Visibility = System.Windows.Visibility.Collapsed;
}
}
I have a MediaElement that displays a simple progress bar when buffering. It gets displayed or hidden on the BufferingProgressChanged event. For the code, see below.
The problem is that quite often the MediaElement decides to buffer twice, causing the progress bar to show up twice. Why is this and is there a way to fix this?
Thanks!
private void MediaElement_BufferingProgressChanged(object sender, RoutedEventArgs e)
{
if (MediaElement.CurrentState == MediaElementState.Buffering)
{
BufferProgressBar.Value = MediaElement.BufferingProgress;
BufferGrid.Visibility = System.Windows.Visibility.Visible;
}
else
{
BufferGrid.Visibility = System.Windows.Visibility.Collapsed;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可以尝试通过存储 MediaElement 的最后状态来解决此问题,这样您就可以检查它是否正在从 Playing 或 Buffering 进行缓冲。
I think you can try to fix this problem by storing the last status of MediaElement, so then you are able to check whether it's buffering from Playing or Buffering.