public void Play(string filename, bool loop = false) { Stop(); var stream = File.OpenRead(filename); var data = SoundLoader.Open(stream); sound = dev.CreateStreaming(data); sound.Volume = Volume; sound.Stopped += Sound_Stopped; sound.Begin(loop); }
public void Play(string filename, float attenuation = 0, bool loop = false) { Stop(); var stream = File.OpenRead(filename); var data = SoundLoader.Open(stream); sound = dev.CreateStreaming(data, filename); sound.Stopped += Sound_Stopped; this.attenuation = attenuation; UpdateGain(); sound.Begin(loop); }
public void LoadStream(Stream stream) { using (var snd = SoundLoader.Open(stream)) { byte[] data; if (snd.Size != -1) { data = new byte[snd.Size]; System.Diagnostics.Trace.Assert(snd.Data.Read(data, 0, snd.Size) == snd.Size); } else { using (var mem = new MemoryStream()) { snd.Data.CopyTo(mem); data = mem.GetBuffer(); } } Al.BufferData(ID, snd.Format, data, data.Length, snd.Frequency); } }