我有一个麦克风对象来录制声音。如果我在同一个 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)];
使用麦克风类有什么问题吗?它会被清除还是在按下设备后退按钮后会发生什么?
提前致谢。如果对问题有任何疑问,请告诉我。