public PlayState(StateManager stateManager, GameWorld gameWolrd) : base(stateManager) { _gameWorld = gameWolrd; backgroundSound = new AudioClip(Path.Combine("Content", "Sounds", "rainfall.ogg")); backgroundSound.Play(); }
/// <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; } } }
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; } }
internal void AddClip(AudioClip clip) { lock (workWithListMutex) { StaticClips.Add(clip); } }
/// <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 } }