コード例 #1
0
        /// <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);
        }
コード例 #2
0
        internal void RemoveSession(SoundBufferSession session)
        {
            // this should only happen inside Dispose().
            if (mSessions == null)
            {
                return;
            }

            mSessions.Remove(session);
        }
コード例 #3
0
        internal void AddSession(SoundBufferSession session)
        {
            if (mSessions == null)
            {
                return;
            }

            if (mSessions.Contains(session) == false)
            {
                mSessions.Add(session);
            }
        }
コード例 #4
0
        /// <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);
        }