0

I have a capture card and I ant to display the Video and play the input Sound. I got the video input by using the CaptureElement and MediaCapture

Capturemanager = new MediaCapture();

        DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

            device = devices[0];

       

        var mediaInitSettings = new MediaCaptureInitializationSettings { VideoDeviceId = device.Id };

        await Capturemanager.InitializeAsync(mediaInitSettings);

        CamCaptureElement.Source = Capturemanager;
        await Capturemanager.StartPreviewAsync();

But this does not work for the input microphone. I tried it tis way:

            AudioCapturemanager = new MediaCapture();

        DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.AudioCapture);

            audioDevice = devices[0];

        var mediaInitSettings = new MediaCaptureInitializationSettings { VideoDeviceId = audioDevice.Id };
        mediaInitSettings.StreamingCaptureMode = StreamingCaptureMode.Audio;
        await AudioCapturemanager.InitializeAsync(mediaInitSettings);

        CamCaptureElement.Source = AudioCapturemanager;
        await AudioCapturemanager.StartPreviewAsync();

How can I get the audio and play it instantly?

Thanks

Agredo
  • 131
  • 1
  • 10

1 Answers1

1

When capturing audio, you used VideoDeviceId. You could try to use AudioDeviceId instead.

dear_vv
  • 2,350
  • 1
  • 4
  • 13
  • Thank you! I used AudioGraph. With MediaCapture It did not work. – Agredo Mar 23 '21 at 10:58
  • 1
    You could use the [offical sample](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/AudioCreation) to do this, which also uses AudioGraph. The Scenario2 captures the audio and generates a file, Scenario2 plays the audio. – dear_vv Mar 24 '21 at 10:09