/// <summary> /// A media player that takes control of a NotifyIcon icon, /// tooltip and balloon to display status. /// </summary> /// <param name="icon"> /// The notify icon to use to display status. /// </param> public Player(NotifyIcon icon) { notifyIcon = icon; player = new MediaPlayer(); player.BufferingStarted += OnBufferingStarted; player.BufferingEnded += OnBufferingEnded; player.MediaEnded += OnMediaEnded; player.MediaFailed += OnMediaFailed; idleIcon = Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Idle.ico"); playingIcon = Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Playing.ico"); playingMutedIcon = Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Playing-muted.ico"); bufferingIcons = new Icon[] { Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Buffering1.ico"), Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Buffering2.ico"), Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Buffering3.ico"), Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Buffering4.ico"), }; bufferingIconTimer = new DispatcherTimer(DispatcherPriority.Background); bufferingIconTimer.Interval = TimeSpan.FromMilliseconds(300); bufferingIconTimer.Tick += OnBufferingIconTimerTick; currentBufferingIcon = 0; source = null; isIdle = true; UpdateIcon(); }
/// <summary> /// Stop playing and set a given stream as current. /// Unmutes the player. /// </summary> /// <param name="stream">Source stream to set as current.</param> public void Select(PlayerStream stream) { Stop(); source = stream; UpdateIcon(); }
/// <summary> /// Set a given stream as current and play it. /// Unmutes the player. /// </summary> /// <param name="stream">Source stream to play.</param> public void Play(PlayerStream stream) { source = stream; Play(); }