Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Phone 7 Audio Recording Problem
    primarykey
    data
    text
    <p>I'm hoping someone can help me with this. I have found the examples for recording audio using XNA in a Silverlight application. And it works, however, only the first time in. I have all the recording functionality on a seperate WP7 Page and with successive visits to the page it doesn't work. The best I can tell is the microphone.start is getting called but the micophone.status remains stopped. What is weird is the BufferReady keeps getting called and the code within that function is all running but without the microphone really starting nothing is really happening. When you exit the app and come back in again the first time visit to the page and everything works fine, but a revisit to the page and it doesn't. </p> <pre><code> void microphone_BufferReady(object sender, EventArgs e) { this.Dispatcher.BeginInvoke(() =&gt; { microphone.GetData(buffer); stream.Write(buffer, 0, buffer.Length); TimeSpan tsTemp = timer.Elapsed; TextBlockSeconds.Text = tsTemp.Hours.ToString().PadLeft(2, '0') + ":" + tsTemp.Minutes.ToString().PadLeft(2, '0') + ":" + tsTemp.Seconds.ToString().PadLeft(2, '0'); if(timer.Elapsed.Seconds &gt;5) DoStop(); }); } private void ButtonRecord_Click(object sender, RoutedEventArgs e) { DisableRecordButton(); timer = new Stopwatch(); timer.Start(); stream = new MemoryStream(); TextBlockSeconds.Text = "00:00:00"; TextBlockStatus.Text = "Recording: "; microphone.BufferDuration = TimeSpan.FromMilliseconds(500); buffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)]; microphone.BufferReady += new EventHandler&lt;EventArgs&gt;(microphone_BufferReady); microphone.Start(); } private void DoStop() { if (timer.IsRunning) timer.Stop(); if (microphone.State == MicrophoneState.Started) { microphone.Stop(); TextBlockStatus.Text = "Stopped: Ready to save"; } else { TextBlockStatus.Text = "Ready: "; } TextBlockSeconds.Text = string.Empty; EnableRecordButton(); } </code></pre> <p>Update... I found the problem but no solution. I was calling the microphone.stop via code on a timer (so I could limit the recorded audio to 5 seconds). Exact same code to execute when a manual stop button would be clicked. When clicking the manual stop button everything worked fine, could re-visit the page and all would be fine. When the stop was called in code from the timer, next visit to the page would not work. So I implemented it with only a manual stop button but really would have been nice to do it automatically (and to know what the real issue was). </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