I’ve embedded a Silverlight video file which is 15 MB in my silverlight assembly. I use Application.GetResourceStream to read the resource as an stream and then I pass the returned stream to the MediaElement control to start playing it.
Question: Does Application.GetResourceStream read the whole embedded file at once? If yes, Is there any solution to prevent this behaviour?
Note: I’m building an OOB silverlight application and it’s going to be published using offline media(CD ROM), so don’t worry about the enlarged xap file.
Thanks in advance.
The clue is in the name Stream. That means it opens a file and reads from it sequentially (like a flowing stream).
Because of the nature of video players, which decompress streams on the fly, it will buffer a certain amount internally before playback starts. This allows the playback to stay ahead of the incoming data. For a locally stored file that will only be a small amount of data.
Why were you concerned about it reading the whole file? Are you having performance problems or long delays?