Ejemplo n.º 1
0
        public async Task PlayTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            var cancellationToken = cancellationTokenSource.Token;

            CheckDevices();

            var settings = new AudioSettings();

            using var recorder  = new NAudioRecorder();
            using var player    = new NAudioPlayer();
            using var recording = await recorder.StartAsync(settings, cancellationToken);

            await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);

            var bytes = await recording.StopAsync(cancellationToken);

            await player.PlayAsync(bytes, settings, cancellationToken);
        }