简体   繁体   English

我在C#中播放音频有哪些选择/资源?

[英]What are my options/resources for playing audio in C#?

I'm aware of how to play sound in C#, for example: 我知道如何在C#中播放声音,例如:

System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\local_file.wav");
player.Play();

However, I wanted to know if C# contained some sort of sound library, like files that are built in to the system that I can use, or something that generates sound (eg text to speech.) Basically, I just want to know what my options are for playing sound in my program, and/or whether I have any "resources" other than my own downloaded files. 但是,我想知道C#是否包含某种声音库,例如我可以使用的内置在系统中的文件,或生成声音的东西(例如,文本到语音)。基本上,我只是想知道我的声音。选项用于在程序中播放声音,和/或是否具有我自己下载的文件以外的任何“资源”。

C# is a progamming language. C#是一种编程语言。 It runs on many different platforms, each of which support many different libraries. 它运行在许多不同的平台上,每个平台都支持许多不同的库。

The SoundPlayer class in the .Net System.media namespace is one very good choice for Windows. .Net System.media命名空间中的SoundPlayer类对于Windows是一个非常好的选择。 Similarly NAudio or IRKlang might be good choices for doing audio in C# on Linux. 同样,在Linux上使用C#进行音频处理时, NAudioIRKlang可能是不错的选择。

There isn't necessarily any "single best, one size fits all" choice. 不一定有任何“最佳选择,一种尺寸适合所有需求”的选择。 You have many different options, depending on your platform, your requirements, and your personal preferences. 根据平台,要求和个人喜好,您有许多不同的选择。

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

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