问题
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