我在Windows Phone 8 App中有以下代码:
FrameworkDispatcher.Update();
microphone = Microphone.Default;
microphone.BufferReady += Device_BufferReady;
bStarted = true;
tbData.Text = "00:00:00";
m_lDuration = 0;
microphone.BufferDuration = TimeSpan.FromMilliseconds(100);
baBuffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];
microphone.Start();
然而,Device_BufferReady永远不会被击中!知道我做错了什么?
答案 0 :(得分:0)
开发中心(http://code.msdn.microsoft.com/wpapps/Microphone-Sample-b2ebe8b6)上提供的示例代码使用了一个周期为33毫秒的自动收录器,您可以从中调用FrameworkDispatcher.Update()方法......
// Timer to simulate the XNA Framework game loop (Microphone is
// from the XNA Framework). We also use this timer to monitor the
// state of audio playback so we can update the UI appropriately.
DispatcherTimer dt = new DispatcherTimer();
dt.Interval = TimeSpan.FromMilliseconds(33);
dt.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } };
dt.Start();
你实现了吗?