Silverlight MediaElement不再播放

编程入门 行业动态 更新时间:2024-10-28 08:26:28
本文介绍了Silverlight MediaElement不再播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个媒体元素,我提供了一个来自微软翻译服务的来源。这是一个小问题因为它给了我一个wav文件。我使用WAVmss库来帮助我,它很有效,但有一点。它是第一次将文件加载到元素中时播放,但是当我第二次尝试播放它时它不会播放?回放代码不能简单:

I have a media element which I give a source I get from Microsofts translation service. This is a slight problem because it gives me a wav file. I used the WAVmss library to help me and it works great, but for one thing. It plays the first time I load the file into the element, but when I try and play it a second time it doesn''t play? The playback code could not be simpler:

private void Play() { mediaElement.Stop(); mediaElement.Position = TimeSpan.Zero; mediaElement.Play(); }

我已调试过。 Position属性确实设置为零,当我再次点击它后闯入它的位置已经移动到最后。 想法?

I have debugged. The Position property does get set to zero, ,and when I break in after clicking it again its position has moved to the end. An ideas?

推荐答案

尝试: Try: if (mediaElement.CurrentState == MediaElementState.Playing) { mediaElement.Pause(); } else { if (mediaElement.CurrentState == MediaElementState.Paused) { if (mediaElement.Position == mediaElement.NaturalDuration.TimeSpan) { mediaElement.Position = new TimeSpan(0); } mediaElement.Play(); } }

我遇到了同样的问题,感谢Gilles Khouzam 快速回复问题已经解决。 好的,我发现了问题.SeekAsync的实现,流中的位置发生了变化但是块中的剩余计数没有。在WaveMediaStreamSource.cs中,查找SeekAsync方法并将代码更改为此(添加MoveToChunkOffest行): I had the same issue and thanks to Gilles Khouzam quick response the problem has been solved. "Ok, I found the issue. The implementation of SeekAsync, the position in the stream was changed but the remaining count in the chunk was not. In WaveMediaStreamSource.cs, look for the SeekAsync method and change the code to this (add the MoveToChunkOffest line):" this.currentPosition = this.wavParser.WaveFormatEx.BufferSizeFromAudioDuration( seekToTime ) + this.startPosition; this.wavParser.MoveToChunkOffset( ( uint ) this.wavParser.WaveFormatEx.BufferSizeFromAudioDuration( seekToTime ) ); this.currentTimeStamp = seekToTime; ReportSeekCompleted( seekToTime );

更多推荐

Silverlight MediaElement不再播放

本文发布于:2023-07-11 11:53:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093956.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Silverlight   MediaElement

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!