N
N
Nikolay L2018-08-28 14:16:29
C++ / C#
Nikolay L, 2018-08-28 14:16:29

Playing an audio file in a separate device?

using System;
using NAudio.Wave;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (var dev in DirectSoundOut.Devices) 
            {
                Console.WriteLine($"{dev.Guid} {dev.Description}"); 
                var outputDevice = new DirectSoundOut(dev.Guid);
                var audioFile = new AudioFileReader(@"C:\Users\777\Desktop\Sample.wav"); // аудио файл
                outputDevice.Init(audioFile);
                outputDevice.Play();
                Console.ReadKey();
            }
        }
    }
}

Console output:
5b852bae1124c150534713.pngProblem
Can't play audio file on a separate device.
Starts playing everywhere.
How to play a file in a separate device?
How to make a check?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2018-08-28
@GavriKos

Well, where is the check on which device to play?
You iterate through all the output devices in a loop and say Play to each one - that's what plays on everyone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question