我有一个媒体元素,我提供了一个来自微软翻译服务的来源。这是一个小问题因为它给了我一个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不再播放
发布评论