示例#1
0
文件: PlayState.cs 项目: mokujin/DN
        public PlayState(StateManager stateManager, GameWorld gameWolrd)
            : base(stateManager)
        {
            _gameWorld = gameWolrd;

            backgroundSound = new AudioClip(Path.Combine("Content", "Sounds", "rainfall.ogg"));
            backgroundSound.Play();
        }
示例#2
0
        /// <summary>
        /// Plays the audio clip on the first free channel.
        /// </summary>
        /// <param name="clip">The audio clip to play.</param>
        public void PlayClip(AudioClip clip)
        {
            // TODO: If all channels are busy, the clip will be ignored.  There must be a more elegant way.
            foreach (AudioChannel channel in Channels)
            {

                    if (channel.IsFree)
                    {
                        channel.Init(clip);
                        channel.Play();
                        return;
                    }
            }
        }
示例#3
0
        public void Init(AudioClip clip)
        {
            ALSourceState state = AL.GetSourceState(Source);
            if (state == ALSourceState.Playing || state == ALSourceState.Paused)
            {
                Stop();
            }
            if (clip != CurrentClip)
            {
                CloseReader();
                CurrentClip = clip;
                OpenReader();

                CurrentFormat = Reader.Channels == 1 ? ALFormat.Mono16 : ALFormat.Stereo16;
                CurrentRate = Reader.SampleRate;
            }
        }
示例#4
0
 internal void AddClip(AudioClip clip)
 {
     lock (workWithListMutex)
     {
         StaticClips.Add(clip);
     }
 }
示例#5
0
        /// <summary>
        /// Plays the audio clip on the first free channel.
        /// </summary>
        /// <param name="clip">The audio clip to play.</param>
        public AudioRemoteControll PlayClip(AudioClip clip)
        {
            // TODO: If all channels are busy, the clip will be ignored.  There must be a more elegant way.
            lock (workWithListMutex)
            {
                foreach (AudioChannel channel in Channels)
                {

                    if (channel.IsFree)
                    {
                        channel.Init(clip);
                        channel.Play();
                        return channel.CreateRemote();
                    }
                }
                return null; // All channels are busy
            }
        }