private void SetVideo(MediaElement player, AudioVisual audioVisual) { player.Close(); if (audioVisual.Video != null) { player.Source = audioVisual.Video; player.Play(); } }
private void SetText(TextBlock display, AudioVisual audioVisual) { if (audioVisual.Text == null) { display.Text = null; } else { display.Text = audioVisual.Text.String; display.Foreground = audioVisual.Text.Color; display.FontFamily = audioVisual.Text.Font; display.FontSize = audioVisual.Text.Size; display.FontStyle = audioVisual.Text.Style; } }
private void SetImage(Image display, AudioVisual audioVisual) { if (audioVisual.Image == null) { display.Source = null; } else { try { display.Source = new BitmapImage(audioVisual.Image); display.HorizontalAlignment = audioVisual.HorizontalAlignment; } catch ( Exception ) { // Don't display image. } } }
private void SetSound(MediaPlayer player, AudioVisual audioVisual) { player.Close(); if (audioVisual.Sound != null) { if ( player == SceneSoundPlayer ) { player.Volume = 0.25; } else if ( player == EffectSoundPlayer ) { player.Volume = 1; } player.Open(audioVisual.Sound); player.Play(); } }
private void SetBackground(Panel panel, AudioVisual audioVisual) { if (audioVisual.Background == null) { panel.Background = Brushes.Black; } else { panel.Background = audioVisual.Background; } }
private void StartEffectTimer(AudioVisual newEffect, double delay) { EffectTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(delay) }; EffectTimer.Tick += delegate { EffectTimer.Stop(); PlayEffect(newEffect); }; EffectTimer.Start(); }
private void PlayEffect(AudioVisual newEffect, double delay) { if (delay == 0) { PlayEffect(newEffect); } else { StartEffectTimer(newEffect, delay); } }
private void PlayEffect(AudioVisual newEffect) { EnteredName = String.Empty; RemoveEffect(); if (newEffect.ContainsVisuals) { FadeInEffect(newEffect.FadeDuration); } else { EffectSoundPlayer.MediaEnded += StopEffectOnSoundEnded; } if (newEffect.ContainsAudio) { SetSound(EffectSoundPlayer, newEffect); EffectSoundPlayer.MediaOpened += DisplayVisualsOnSoundLoaded; } else { SetBackground(EffectPanel, newEffect); SetImage(EffectImageDisplay, newEffect); SetSound(EffectSoundPlayer, newEffect); SetVideo(EffectVideoPlayer, newEffect); SetText(EffectTextDisplay, newEffect); } CurrentEffect = newEffect; }
private void PlayScene(AudioVisual scene) { EnteredName = String.Empty; StopEverything(); SetBackground(ScenePanel, scene); SetImage(SceneImageDisplay, scene); SetSound(SceneSoundPlayer, scene); SetVideo(SceneVideoPlayer, scene); }