Search code examples
c#naudiowindows-media-playeraxwindowsmediaplayer

Play mutiple videos from my application with audio on different devices


My application currently uses the AXWindowsMediaPlayer component to play videos and in turn sound is played using the default sound device.

I need to add support for playing multiple videos and in turn I need to be able to setup audio sources for each of the videos.

Thoughts on how to achieve this:

  1. Set the audio endpoint of the AXWindowsMediaPlayer to my specified device (I Know I can do this in windows media player program but don't know how in code).
  2. Play the video using WMP and stream the audio using NAudio.

Can anyone provide some recommendations on how best to achieve what I need and perhaps a link to some documentation I need to be looking at? I can't seem to find anything on this.


Solution

  • I ended up using NAUDIO for this.

    This is the code I used:

    var waveReader = new MediaFoundationReader(playListItem.FilePath);
    _waveOut = new WaveOut {DeviceNumber = playListItem.PlayerScreen.AudioDevice.Id};
    _waveOut.Init(waveReader);
    wmPlayer.settings.volume = 0;
    wmPlayer.URL = playListItem.FilePath;
    _waveOut.Play();