简体   繁体   English

如何静音或只选择一个音频通道?

[英]How to mute or select only one audio channel?

I'd know how can I mute or select only one audio channel in C#.我知道如何在 C# 中静音或仅选择一个音频通道。 I have to play an audio file only in the left/right channel.我只能在左/右声道中播放音频文件。 Is it possible?可能吗? What do I have to do?我需要做什么?

You will likely need to use the Balance property of System.Windows.Media.MediaPlayer.您可能需要使用 System.Windows.Media.MediaPlayer 的 Balance 属性。

MSDN MediaPlayer Balance Property MSDN MediaPlayer Balance 属性

Set it to -1 for the left and 1 for the right channel.将左声道设置为 -1,右声道设置为 1。

    MediaPlayer mediaPlayer = new MediaPlayer();

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        mediaPlayer.Open(new Uri(@"C:\temp\Kalimba.mp3"));

        if (DateTime.Now.Second % 2 == 0)
        {
            mediaPlayer.Balance = 1;
            mediaPlayer.Play();
        }
        else
        {
            mediaPlayer.Balance = -1;
            mediaPlayer.Play();
        }
    }

System.Media.SoundPlayer lacks the possability of adjusting the balance. System.Media.SoundPlayer缺乏调整平衡的可能性。 You should try something different.你应该尝试一些不同的东西。 System.Media.SoundPlayer simply controls playback of a sound from a .wav file System.Media.SoundPlayer 仅控制 .wav 文件中声音的播放

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM