2013-07-05 66 views
0

我想捕捉麥克風並立即播放。我正在尋找解決方案,如何使用Windows 8下的MediaCapture元素來捕獲麥克風中的音頻數據,但我只找到了如何捕獲網絡攝像頭。如果有人可以告訴我如何在回放之前修改數據,那將會非常棒。請給我一個答案。無論答案是否在c#或C++中都沒有關係。MediaCapture如何使用錄製音頻

+0

[MSDN具有用於樣品'MediaCapture'](http://code.msdn.microsoft.com/windowsapps/media-capture-sample-adf87622) – Xyroid

回答

0

我寫了一個桌面應用程序,但同樣的事情應該在幾乎任何地方工作。

private void RecordAudio() 
    { 
     var capture = new MediaCapture(); 
     var settings = new MediaCaptureInitializationSettings(); 
     settings.StreamingCaptureMode = StreamingCaptureMode.Audio; 

     capture.InitializeAsync(settings).Completed = (info, status) => 
      { 
       StorageFolder folder = KnownFolders.DocumentsLibrary; 
       var op = folder.CreateFileAsync("sample.mp3", CreationCollisionOption.ReplaceExisting); 

       op.Completed = (
        i, s) => 
        { 
         var file = i.GetResults(); 
         var profile = MediaEncodingProfile.CreateMp3(AudioEncodingQuality.High); 
         capture.StartRecordToStorageFileAsync(profile, file); 
        }; 
      }; 

    }