我希望根据所有需要的信息创建AudioFormat类的实例。
基本上,我拥有的是
int BitsPerSampleint Channelsint SamplesPerSecondWaveFormatType WaveFormat问题是,简单地使用类似于
AudioFormat format = new AudioFormat();
format.BitsPerSample = BitsPerSample;
[...]不起作用,因为Property or indexer 'System.Windows.Media.AudioFormat.BitsPerSample' cannot be assigned to -- it is read only。
有什么简单的方法可以创建这样的对象吗?如果没有,我应该做些什么来创建它?使用继承,覆盖属性以使其具有setter?创建对象的XML表示,然后反序列化它?使用其他一些丑陋的黑客(没有unsafe :- )?
发布于 2011-04-17 19:10:33
不应该直接创建这个类。
它存在于使用内部构造函数从AudioCaptureDevice类、SupportedFormats属性返回信息。
如果您试图将其用于您自己的目的,则应该创建您自己的类。
https://stackoverflow.com/questions/5695740
复制相似问题