/// <summary> /// Raised when a message is recieved from the foreground app /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BackgroundMediaPlayer_MessageReceivedFromForeground(object sender, MediaPlayerDataReceivedEventArgs e) { var message = MessageHelper.ParseMessage(e.Data); if (message is AppSuspendedMessage) { AppSuspended?.Invoke(this, null); } else if (message is AppResumedMessage) { AppResumed?.Invoke(this, null); } else if (message is StartPlaybackMessage) { StartPlayback?.Invoke(this, null); } else if (message is SkipNextMessage) { SkipToNext?.Invoke(this, null); } else if (message is SkipPreviousMessage) { SkipToPrev?.Invoke(this, null); } else { var changedMessage = message as TrackChangedMessage; if (changedMessage != null) { TrackChanged?.Invoke(this, changedMessage.QueueId); } else { var playlistMessage = message as UpdatePlaylistMessage; if (playlistMessage != null) { UpdatePlaylist?.Invoke(this, playlistMessage.Tracks); } else { var addMessage = message as AddToPlaylistMessage; if (addMessage != null) { AddToPlaylist?.Invoke(addMessage.Tracks, addMessage.Position); } else { var updateMessage = message as UpdateUrlMessage; if (updateMessage != null) { TrackUpdateUrl?.Invoke(this, updateMessage); } } } } } }
/// <summary> /// Click event handeler for Play Button /// </summary> /// <param name="sender">Object triggering the summoning event</param> /// <param name="e"><see cref="EventArgs"/> passed from sender</param> private void play_button_Click(object sender, EventArgs e) { if (!play_button_toggle) { play_button.Image = Properties.Resources.pause; StartPlayback?.Invoke(this, new EventArgs()); record_button.Enabled = false; } else { play_button.Image = Properties.Resources.play; PauseAudio?.Invoke(this, new EventArgs()); record_button.Enabled = true; } play_button_toggle = !play_button_toggle; }