public void Replay(ref SoundBuffer voice) { voice.Wave.Stop(); voice.Reader.CurrentTime = TimeSpan.FromSeconds(0); voice.Wave.Init(voice.Reader); voice.Wave.Play(); }
//Play=0:Pause Play=1:Play/Resume Play=Other:Auto Pause/Play public void Pause(ref SoundBuffer voice, int Play = -1) { switch (voice.Wave.PlaybackState) { case PlaybackState.Stopped: if (Play != 0 || Play == 1) { voice.Reader.CurrentTime = TimeSpan.FromSeconds(0); voice.Wave.Init(voice.Reader); voice.Wave.Play(); } break; case PlaybackState.Paused: if (Play != 0 || Play == 1) { voice.Wave.Resume(); } break; case PlaybackState.Playing: if (Play != 1 || Play == 0) { voice.Wave.Pause(); } break; } }
public void GetStream(System.IO.Stream data, ref SoundBuffer voice) { if (voice == null) { voice = new SoundBuffer(); } voice.Reader = new WaveFileReader(data); voice.Wave = new WaveOut(); }
public void Play(ref SoundBuffer voice) { try { voice.Reader.CurrentTime = TimeSpan.FromSeconds(0); voice.Wave.Init(voice.Reader); voice.Wave.Play(); }catch (Exception e) { Console.WriteLine(e); } }
public bool Dispose(ref SoundBuffer voice) { try { voice.Wave.Dispose(); voice.Reader.Dispose(); voice = null; return(true); } catch { return(false); } }
public void Stop(ref SoundBuffer voice) { voice.Wave.Stop(); }