示例#1
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 public CachedSoundProvider(CachedSound sound, long position)
 {
     _sound = sound;
     if (position < _sound.AudioData.Length)
     {
         _position = position;
     }
 }
示例#2
0
        /// <summary>
        /// Returns current position in specified looping sound, or 0 if not looping sound.
        /// </summary>
        public long GetLoopPosition(CachedSound sound)
        {
            long position = 0;

            lock (_loops)
            {
                CachedSoundProvider provider = _loops
                                               .Where(p => p.Sound == sound)
                                               .FirstOrDefault();
                if (provider != null)
                {
                    position = provider.Position;
                }
            }
            return(position);
        }
示例#3
0
        /// <summary>
        /// Plays a cached sound, looping forever until stop.  Keeps playing if already looping specified sound.
        /// </summary>
        public void PlayLoop(CachedSound sound, bool stopOtherLoops = true, long position = 0)
        {
            CachedSoundProvider provider;

            lock (_loops)
            {
                if (stopOtherLoops)
                {
                    _loops.Where(p => p.Sound != sound).ToList().ForEach(p => StopLoop(p.Sound));
                }
                if (_loops.Where(p => p.Sound == sound).Any())
                {
                    return;
                }
                provider = new CachedSoundProvider(sound, position);
                _loops.Add(provider);
            }
            AddMixerInput(provider);
        }
示例#4
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 public CachedSoundProvider(CachedSound sound)
 {
     _sound = sound;
 }
示例#5
0
 /// <summary>
 /// Plays a cached sound.
 /// </summary>
 public void PlaySound(CachedSound sound)
 {
     AddMixerInput(new CachedSoundProvider(sound));
 }