【问题标题】:How I play my audios with match all text in text box [closed]我如何在文本框中匹配所有文本来播放我的音频[关闭]
【发布时间】:2012-07-12 04:21:38
【问题描述】:
        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();
            }

            }

        }
        }

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

【问题讨论】:

    标签: c# c#-4.0 audio media-player multimedia


    【解决方案1】:

    在每个if (word.Contains){...} 之后使用break

    并使用SoundPlayer.PlaySync Method 而不是SoundPlayer.Play。这样你就可以在上一个声音结束后开始下一个声音。

    【讨论】:

    • 非常感谢,我现在使用 break 它只播放第一个角色,请帮助播放其他角色。
    • 我更新了我的答案。使用SoundPlayer.PlaySync
    • thanxthanxthanxthanx 很多..................................................
    • yes.OHHHH,我还有一个问题,它会播放所有角色。但它播放的顺序不正确,它只播放我定义的顺序。我该如何解决这个问题。请帮助我............
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多