开发者

WPF MediaElement, change audio track

I'm writing a Media Player using WPF and the MediaElement. I was playing a video i have that has several audio tracks. But they are both playing at the same time :(

How do i just play one of them 开发者_开发百科? is it at all possible ?


I think this problem is in the audio and video DirectShow codecs you use. Can you play the video correct in the Windows Media Player? If no, please re-install the appropriated codecs.

Some months ago I have completely prototyped the requirements to switch audio tracks in order to show the video-help in our multi-language software. My experience shows some alternatives:

  • Use the WMP-control via WinForms host, and then change the language like:

    var control = ((IWMPControls3)wmpControl.Ctlcontrols);
    control.currentAudioLanguage = 9; // english

The Complete list of the LCID you can find here. To list all audio tracks in the video you can use something like:

wmpControl.PlayStateChange += (o, args) => {
  if(args.newState == 3) {
    var control = ((IWMPControls3)wmpControl.Ctlcontrols);
    for(int i = 1; i <= control.audioLanguageCount; i++) {
      MessageBox.Show(control.getAudioLanguageID(i) + ": " + control.getAudioLanguageDescription(i));
    }
  }
};
  • Use the separate audio tracks and play it synchronously to the video using the MediaPlayer. The main problem of this method is, that you must synchronize audio and video playback, start, stop, seeking,.. manually.

I hope this helps you to choose your solution.


It is not possible with the WPF MediaElement. If you have some DirectShow know-how, you can try my WPF MediaKit and either modify the MediaUriElement/Player or create your own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜