/// <summary> /// Handles playing of <see cref="ActionSound"/>s. /// </summary> private async void OnSoundPlayed(object sender, ActionSound sound) { if (!await _interopSounds.Play(sound)) { Console.WriteLine($"ERROR '{nameof(InteropSounds)}':Could not play sound: {sound}"); } }
/// <summary> /// Call JavaScript to play a sound. /// </summary> /// <param name="sound">Sound to play.</param> /// <returns>Indication if the sound was played successfully.</returns> public async Task <bool> Play(ActionSound sound) { //Returns null so use object type return(await _jsRuntime.InvokeAsync <bool>( $"{JsAsteroidsSound}.{play}" , sound )); }
/// <summary> /// Playes associated <see cref="ISimpleAudioPlayer"/>. /// </summary> private void OnSoundPlayed(object sender, ActionSound e) { Device.BeginInvokeOnMainThread(() => { var player = _soundPlayers[e]; player.Play(); } ); }
public void PlaySound(MinionAction action) { if (minionSounds == null) { setupMinionSounds(); } ActionSound actionSound = minionSounds.getActionSoundFromAction(action); LaunchSound(actionSound.sound, actionSound.mixerGroup); }
private void OnSoundPlayed(object?sender, ActionSound sound) { if (ActiveSoundPlayer != null) { return; } ActiveSoundPlayer = SoundPlayers[sound]; Task.Factory.StartNew(() => { ActiveSoundPlayer.Stream.Position = 0; ActiveSoundPlayer.PlaySync(); ActiveSoundPlayer = null; }); }
private void OnSoundPlayed(object sender, ActionSound sound) { if (_soundPlaying != null) { return; } _soundPlaying = _soundPlayers[sound]; Task.Factory.StartNew(() => { _soundPlaying.Stream.Position = 0; _soundPlaying.PlaySync(); _soundPlaying = null; }); }
private async void OnSoundPlayed(object?sender, ActionSound sound) { if (sound != ActionSound.Thrust) { await PlaySoundAsync(XAudio2, Controller.ActionSounds[sound]); return; } if (!SoundLocker.TryLock(sound, out var @lock)) { return; } using (@lock) { await PlaySoundAsync(XAudio2, Controller.ActionSounds[sound]); } }
void ButtonPressedAudio(ActionSound soundToPlay) { switch (soundToPlay) { case ActionSound.roundStarted: src.clip = roundStarted; break; case ActionSound.p1Call: src.clip = playerOneCalled; break; case ActionSound.p1Check: src.clip = playerOneChecked; break; case ActionSound.p1Raise: src.clip = playerOneRaised; break; case ActionSound.p1Fold: src.clip = playerOneFolded; break; case ActionSound.p2Call: src.clip = playerTwoCalled; break; case ActionSound.p2Check: src.clip = playerTwoChecked; break; case ActionSound.p2Raise: src.clip = playerTwoRaised; break; case ActionSound.p2Fold: src.clip = playerTwoFolded; break; default: break; } src.Play(); }
private void PlaySound(object sender, ActionSound sound) { SoundPlayed?.Invoke(sender, sound); }
/// <summary> /// Invokes <see cref="SoundTriggered"/> to play an <see cref="ActionSound"/>. /// </summary> /// <param name="sender">Calling object.</param> /// <param name="sound">Sound to play.</param> public static void PlaySound(object sender, ActionSound sound) { SoundTriggered?.Invoke(sender, sound); }
/// <summary> /// Handles playing of <see cref="ActionSound"/>s. /// </summary> private async void OnSoundPlayed(object sender, ActionSound sound) { await _interopSounds.Play(sound.ToString().ToLowerInvariant()); }