/// <summary> /// Creates a SoundBufferSession object and starts it playing. /// You can ignore the return value of this function if you just /// want simple playback. /// </summary> /// <returns></returns> public SoundBufferSession Play() { SoundBufferSession sb = NewSoundBufferSession(); sb.Play(); return(sb); }
internal void RemoveSession(SoundBufferSession session) { // this should only happen inside Dispose(). if (mSessions == null) { return; } mSessions.Remove(session); }
internal void AddSession(SoundBufferSession session) { if (mSessions == null) { return; } if (mSessions.Contains(session) == false) { mSessions.Add(session); } }
/// <summary> /// Creates a new SoundBufferSession object, or finds one which /// can be recycled. /// </summary> /// <returns></returns> private SoundBufferSession NewSoundBufferSession() { if (mIsDisposed) { throw new ObjectDisposedException("Cannot access a disposed SoundBuffer."); } foreach (SoundBufferSession s in mSessions) { if (s.IsPlaying == false && s.Recycle) { s.Initialize(); return(s); } } SoundBufferSession retval = new SoundBufferSession(this); mSessions.Add(retval); return(retval); }