Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to play non buffered WAV with MediaStreamSource implementation in Silverlight 4?
    primarykey
    data
    text
    <p><strong>Background</strong></p> <p>I'm trying to stream a wave file in Silverlight 4 using MediaStreamSource implementation found <a href="http://blogs.msdn.com/b/gillesk/archive/2009/03/23/playing-back-wave-files-in-silverlight.aspx" rel="nofollow noreferrer">here</a>. The problem is I want to play the file while it's still buffering, or at least give user some visual feedback while it's buffering. For now my code looks like that:</p> <pre><code>private void button1_Click(object sender, RoutedEventArgs e) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(App.Current.Host.Source, "../test.wav")); //request.ContentType = "audio/x-wav"; request.AllowReadStreamBuffering = false; request.BeginGetResponse(new AsyncCallback(RequestCallback), request); } private void RequestCallback(IAsyncResult ar) { this.Dispatcher.BeginInvoke(delegate() { HttpWebRequest request = (HttpWebRequest)ar.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ar); WaveMediaStreamSource wavMss = new WaveMediaStreamSource(response.GetResponseStream()); try { me.SetSource(wavMss); } catch (InvalidOperationException) { // This file is not valid } me.Play(); }); } </code></pre> <p>The problem is that after setting <code>request.AllowReadStreamBuffering = false</code> the stream does not support seeking and the above mentioned implementation throws an exception (keep in mind I've put some of the position setting logic into <code>if (stream.CanSeek)</code> block):</p> <blockquote> <p>Read is not supported on the main thread when buffering is disabled</p> </blockquote> <p><strong>Question</strong></p> <p>Is there a way to play WAV stream without buffering it in advance in Silverlight 4?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload