title: Play media file, while it is still downloading (Windows Phone)
body: <p>I would like to know, if there's a way to play a media-file in Windows Phone, while this file is still being downloaded?</p>
  
  <p>At the current time, I have an application with feature, that allows to download and play media files, when they are fully downloaded.
  (I've created this feature, using <a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=586" rel="nofollow">article</a>)</p>
  
  <p>So, in brief, first, the media-file is downloaded from url, then I'm using mediaElement to play it: </p>
  
  <pre><code>mediaElement.source = isolatedStorageFileStream;
  </code></pre>
  
  <p>After that, I can use this file via my player UI.</p>
  
  <p>However, I prefer to make this feature better - allow to start playing file, while the download is still in progress. In the end, this should look like that: start downloading file, contemporaneously start decrypting this file, contemporaneously allow to play decrypted part of file. Let's forget about decryption so far(I've already written a method for a downloaded file, it should be slightly changed then), the main problem is how to allow two parallel tasks: downloading and playing.</p>
  
  <p>The first question is: "Does MediaElement only allow to set "source" property to only solid(finally downloaded) files or it can use this Stream, during downloading, as well"?
  Because, I've found some info, that: </p>
  
  <blockquote>
    <p>"The MediaElement does not supporting streaming at the moment. It
    loads the <em>entire</em> file first before it actually plays it."</p>
  </blockquote>
  
  <p>, though I'm not sure, that this one refers to Windows Phone, it sounds rather anxiously.</p>
  
  <p>If this cannot be done, what else can I use to work with media-files? I'm not interested in downloading video, let's limit only with mp3 audio files.</p>
  
  <p>Right now, the download process is implemented in this way:</p>
  
  <pre><code>WebClient webClient = new WebClient();
  webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
  webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
  webClient.OpenReadAsync(new Uri(link));
  </code></pre>
  
  <p>Then in OpenReadCompleted the download file stream is set as source of mediaFile.</p>
  
  <pre><code>mediaFile.SetSource(isolatedStorageFileStream);
  </code></pre>
  
  <p>After this I can use my media file.</p>
  
  <p>I there a solution for my problem? I'm rather new at Windows Phone threading and streaming and don't know, how to implement such feature.</p>
  
  <p>P.S. Of course, I tried to find a similar question, but failed. If you know one, give me a link, please.</p>
  
  <p>P.P.S. Sorry for my English.</p>