简体   繁体   中英

Stream video from isolated storage in wp7

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

I've found solution, it's very strange, but works

The problem was that I save files with names %clipId%.clip, but when I changed file names to %clipId%.mp4 (my clips are encoded in mp4) it becomes work!!!

Can't understand why it is so.

The media player looks at the filename to check if it supports the format. ".clip" is no valid format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM