[英]Do … While System.Media.SoundPlayer() is in use
I have been trying to display text on my Console Application while a sound file is currently playing, lyrics as an example. 我一直在尝试在播放声音文件的同时在控制台应用程序上显示文本,例如歌词。 How is the best way to do it? 最好的方法是什么?
struct Music
{
public
void PlaySong() {
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = @"C:\Users\MyPC\Music\MoreMusic\songsample.wav";
player.Load();
player.PlaySync();
}
}
class Program
{
static public void Main(string[] args)
{
Music music;
do
{
//Display Lyrics
} while (true); //as the song progresses
}
}
Replace the PlaySync with Play 将PlaySync替换为Play
struct Music
{
public
void PlaySong() {
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = @"C:\Users\MyPC\Music\MoreMusic\songsample.wav";
player.Load();
player.Play();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.