0
        string line = textBox1.Text.ToString();

        string[] words = line.Split();

        foreach (string word in words)
        {

            if (word.Contains("ඉ"))
            {
                SoundPlayer sndplayr = new SoundPlayer(WindowsFormsApplication1.Properties.Resources._a);
                sndplayr.Play();
            }

            if (word.Contains("අ"))
            {
                SoundPlayer sndplayr = new SoundPlayer(WindowsFormsApplication1.Properties.Resources.la);
                sndplayr.Play();
            }

            }

        }
        }

我用过这个,但它只播放文本框最后一个字符的音频。我也想播放其他字符。那我该怎么办。请帮我............

4

1 回答 1

1

break每次后使用if (word.Contains){...}

并使用SoundPlayer.PlaySync 方法代替SoundPlayer.Play. 这样,您可以在上一个声音结束后开始下一个声音。

于 2012-07-12T04:31:44.327 回答