I'm trying to make some wp7 app which should play videos from server. One of the app's features is downloading selected videos and playing them from isolated storage.
I'm using next code for downloading:
WebClient wc = new WebClient();
wc.OpenReadCompleted += (s, a) => { /* saving result stream to isolated storage */}
wc.OpenReadAsync(fileUri);
So, when I click on play button, I check if file was downloaded or not, and if it was I open IsolatedStorageFileStream for this file and set it to player's source, otherwise I set to source file Uri.
Problem is that I get MediaFailed exception when I'm trying to set IsolatedStorageFileStream as MedialElement's source. Can anybody help me with it?
Code looks like in next way
private IsolatedStorageFile isf;
private IsolatedStorageFileStream stream;
private void playButton_Click(..)
{
isf = IsolatedStorageFile.GetUserStoreForApplication();
stream = isf.OpenFile(path, FileMode.Open);
MediaPlayer.SetSource(stream);
MediaPlayer.Play();
}
Stream is not corrupted, its length is correct. I realy don't know what to do with it. Thanks in advance