在 WP7 中按下设备后退键后麦克风缓冲区变为 0
我有一个麦克风对象来录制声音。如果我位于同一个 xaml 文件上,我的字节缓冲区数组会给出正确的结果。
但是一旦我按下后退键并再次来到同一页面,缓冲区的每个数组成员中都包含 0。
在构造函数中,我有以下代码:
this.microphone.GetData(buffer);
在按钮单击处理程序中,我有以下代码:
// Stop previously running microphone
if (this.microphone.State == MicrophoneState.Started)
{
this.microphone.Stop();
}
// Clear previous content of microphone
this.microphone.BufferDuration = TimeSpan.FromMilliseconds(1000);
this.microphone.Start();
// Store recorded audio
this.buffer = new byte[this.microphone.GetSampleSizeInBytes(this.microphone.BufferDuration)];
使用麦克风类有什么问题吗?按下设备后退按钮后它会被清除还是会发生什么?
提前致谢。如果问题有任何疑问,请告诉我。
i have a microphone object to record sound. My byte buffer array gives me correct result if i am on the same xaml file.
But once i press the back key and come to same page again, the buffer contains 0 in every array member.
In constructor, i have the following code:
this.microphone.GetData(buffer);
In a button click handler, i have the following code:
// Stop previously running microphone
if (this.microphone.State == MicrophoneState.Started)
{
this.microphone.Stop();
}
// Clear previous content of microphone
this.microphone.BufferDuration = TimeSpan.FromMilliseconds(1000);
this.microphone.Start();
// Store recorded audio
this.buffer = new byte[this.microphone.GetSampleSizeInBytes(this.microphone.BufferDuration)];
Is there any problem with using microphone class? Does it get cleared or what after coming from a device back button press?
Thanks in advance. Please let me know if there is any doubt in the question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在某个页面上启动麦克风,然后向后导航,该页面以及任何缓冲的录音都将被销毁。当您下次导航到该页面时,将创建该页面的新实例以及新的麦克风(和流/缓冲区)。
这是你的场景吗?
如果我是你,我会在应用程序级别创建麦克风,这样它就不会受到应用程序中页面之间导航的影响。
If you start a microphone on a page then navigate away backwards from it, that page will be destroyed, along with any buffered recording. When you next navigate to that page a new instance of it will be created along with a new microphone (and stream/buffer).
Is this your scenario?
If I were you I'd create the microphone at application level so it doesn't risk being impacted by navigation between pages in the app.