开发者

Silverlight: Can MediaElement play from a downloading stream?

I am trying to find out whether it is possible to play a video in a MediaElement from a stream which is still downloading, rather than waiting for it to finish? I have researched the topic pretty thoroughly, but found no definitive answer.

I am trying to implement playback on demand. I am currently playing the video by assigning the uri to the MediaElement's Source, and this works. I want to change this to play back by opening the uri in a Stream, and assigning the Stream to the MediaElement using SetSource.

I have written code which takes the uri, creates a WebClient, and uses OpenReadAsync to begin reading from it. I've s开发者_开发百科et AllowReadStreamBuffering to false to allow me to get the stream from OpenReadComplete as soon as it's available (rather than waiting for it to finish downloading). As soon as I have a handle to the Stream, I assign it to the MediaElement and attempt playback.

This is currently resulting in a System.Exception: 2210 error. As I know the resource exists and is readable, I don't know whether it's my code that's wrong, or whether it's simply not possible for a MediaElement to play back from a stream that is incomplete.

If this is not possible using SetSource and a Stream, is it possible using SetSource and a MediaStreamSource class? I did look at MediaStreamSource for this task, but it seemed to require me to write code which parsed the incoming stream and extract a frame at a time from it, which sounded painful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜