wpfaudiomediawpf-mediakit

WPF MediaKit Audio Issues


I am currently using the WPF MediaKit in an application I am working on. I am having an issue with audio. On some computers playback would not work at all. It was confusing because it seemed to work sometimes and not others. Then I noticed it was failing to open the media because of an audio issue. If there are no audio devices connected the cannot open the audio stream and fails completely. This is a problem, we can tell people they have to connect speakers for the application to function. Is there a way I can tell it to just ignore the audio if this happens and still play the video? Here is the error I am getting.

System.Runtime.InteropServices.COMException (0x80040256): Cannot play back the audio stream: no audio hardware is available, or the hardware is not responding.
   at DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)
   at WPFMediaKit.DirectShow.MediaPlayers.MediaPlayerBase.AddFilterByDevice(IGraphBuilder graphBuilder, DsDevice device)
   at WPFMediaKit.DirectShow.MediaPlayers.MediaPlayerBase.AddFilterByName(IGraphBuilder graphBuilder, Guid deviceCategory, String friendlyName)
   at WPFMediaKit.DirectShow.MediaPlayers.MediaUriPlayer.InsertAudioRenderer(String audioDeviceName)
   at WPFMediaKit.DirectShow.MediaPlayers.MediaUriPlayer.OpenSource()

Solution

  • 0x80040256 is VFW_E_NO_AUDIO_HARDWARE "Cannot play back the audio stream: no audio hardware is available, or the hardware is not responding." which means that the system does not have audio output device to play to.

    WPFMediaKit however assumes you have some, and attempts to create audio renderer unconditionally. That is, you have to edit this in WPFMediaKit code to work it around.