简体   繁体   中英

Microphone BufferReady event handler doesnt get in windows phone 8 app

i have the following code in 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();

however Device_BufferReady never gets hit! any idea what im doing wrong ?

the sample code provided on the dev center ( http://code.msdn.microsoft.com/wpapps/Microphone-Sample-b2ebe8b6 ) makes use of a ticker with a 33ms period, from which you call the FrameworkDispatcher.Update() method...

        // 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();

Did you implement this?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM