Silverlight: Can a MediaElement play from a downloadable stream?

I'm trying to figure out if it is possible to play a video in MediaElement from a stream that is still loading, and not wait for it to finish? I carefully studied this topic, but did not find a definitive answer.

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

I wrote code that takes uri, creates a WebClient, and uses OpenReadAsync to start reading from it. I set AllowReadStreamBuffering to false to allow me to get the stream from OpenReadComplete as soon as it becomes available (instead of waiting for it to finish loading). As soon as I have a Stream knob, I assign it a MediaElement and try to play it.

As a result, this leads to a System.Exception: 2210 error. Since I know that the resource exists and is readable, I donโ€™t know if this is my code incorrect or it is simply not possible to play the MediaElement from an incomplete stream.

If this is not possible with SetSource and Stream, is it possible to use SetSource and the MediaStreamSource class? I was considering MediaStreamSource for this task, but it seemed to me that I needed to write code that analyzed the incoming stream and extracted a frame from it at a time, which was painful.

+6
source share

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


All Articles