Silverlight. Play video from byte array

若如初见. 提交于 2019-12-13 17:15:12

问题


I have Silverlight application that recieves special structure of media: images and videos. Data is recieved as byte[] for each image or video

To show images, I use:

MemoryStream stream = new MemoryStream(Node.ResourceBin);

BitmapImage bmp = new BitmapImage();
bmp.SetSource(stream);

ImageContainer.Source = bmp;

And it works.

To show video I have tried:

MemoryStream stream = new MemoryStream();

stream.Write(Node.ResourceBin, 0, Node.ResourceBin.Length);
stream.Position = 0;          

VideoContainer.SetSource(stream);                
VideoContainer.Play();

And it doesnt work. I compared length of byte[] and original AVI file and they are equals, so, data recieved correctly.

What's wrong with it?

Thanks


回答1:


Have you verified that Silverlight can play the video without loading it with a stream? Most video issues I've had relate to codec support. – The Real Baumann 9 hours ago

SL plays only WMV format. AVI doesnt play at all. Thanks.

Look here: http://forums.silverlight.net/t/9498.aspx/1

Yes. According to the overview of Silverlight,it currently support (VC-1, WMV, WMA, MP3) and 720P High Definition (HD) Video.




回答2:


From all the comments I believe I know whats going on.

When your loading a video from a resource DO NOT use a stream. Just set the source using Source()

VideoContainer.Source("/GraphManager.WebViewer;component/myvideo.avi");                
VideoContainer.Play();

When your downloading video files from the internet then use a stream



来源:https://stackoverflow.com/questions/9100177/silverlight-play-video-from-byte-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!