本文整理汇总了C#中IDecoder.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IDecoder.Dispose方法的具体用法?C# IDecoder.Dispose怎么用?C# IDecoder.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDecoder
的用法示例。
在下文中一共展示了IDecoder.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AudioBuffer
public AudioBuffer(IDecoder decoder)
{
if (decoder == null)
throw new ArgumentNullException("decoder");
Buffer = AL.GenBuffer();
Util.CheckOpenAlErrors();
var data = new float[decoder.TotalSamples];
var castData = new short[decoder.TotalSamples];
int read = 0;
while (read < data.Length)
{
read += decoder.ReadSamples(data, read, data.Length - read);
}
Util.CastBuffer(data, castData, data.Length);
AL.BufferData(Buffer, Util.ToOpenAL(decoder.Format), castData, castData.Length * sizeof(short), decoder.Frequency);
Util.CheckOpenAlErrors();
decoder.Dispose();
}
示例2: PlayMusic
public void PlayMusic(string filename)
{
StopMusic ();
Stream = File.OpenRead (filename);
MusicDecoder = DecoderFactory.GetDecoderFromStream (Stream);
MusicStreamer = new StreamingAudio (Device, MusicDecoder.Format, MusicDecoder.SampleRate);
MusicStreamer.BufferNeeded += (instance, buffer) => MusicDecoder.Read (buffer.Length, buffer);
MusicStreamer.PlaybackFinished += (sender, e) => {
if (loopMusic)
PlayMusic (filename);
else {
MusicStreamer.Dispose ();
MusicDecoder.Dispose ();
MusicStreamer = null;
}
};
MusicStreamer.Play ();
}