简体   繁体   English

C# 音频播放不好

[英]C# Audio playing badly

I'm making a game to learn how to properly use C#, but the sounds that I use don't play as intended.我正在制作一个游戏来学习如何正确使用 C#,但我使用的声音没有按预期播放。 They make no errors, but play late and the file seems cut.他们没有出错,但玩晚了,文件似乎被剪掉了。

I'm using WinForms, so I tried a SoundPlayer with a Stream, or tried with Visual Basic's Audio class.我正在使用 WinForms,所以我尝试了带有 Stream 的 SoundPlayer,或者尝试了 Visual Basic 的音频 class。

I also tried to make a dictionary full of streams, or full of SoundPlayer, but it didn't change anything.我还尝试制作一个充满流或 SoundPlayer 的字典,但它并没有改变任何东西。

It work when I use the AudioPlayMode.WaitToComplete, but it isn't what I want.当我使用 AudioPlayMode.WaitToComplete 时它可以工作,但这不是我想要的。

Thanks in advance !提前致谢 !

I've figured it out.我已经想通了。 I just put the audio in a Thread, and put Audio.WaitToComplete in it.我只是将音频放在一个线程中,然后将 Audio.WaitToComplete 放入其中。

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

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