/// <summary> /// Handles a click on <see cref="button_play_pause"/>. /// Changes the playback state by communicating with the Zune player. /// </summary> /// <param name="sender">N/A</param> /// <param name="e">N/A</param> /// <seealso cref="ZuneAPI.PauseTrack"/> /// <seealso cref="ZuneAPI.PlayTrack"/> private void button_play_pause_Click(object sender, EventArgs e) { updateMessagesEnabled["playback"] = true; if (zuneAPI.IsPlaying()) { zuneAPI.PauseTrack(); } else { zuneAPI.PlayTrack(); } }
/// <summary> /// Given a message from the client, parse the message to enact changes /// in the equalizer or zune instances. /// </summary> /// <param name="message">The message to be parsed.</param> public void ParseMessage(string message) { // get the message parts string[] messageParts = message.Split(new char[] { ':' }, 2); if (messageParts.Length < 2) { return; } string messageType = messageParts[0]; string restOfMessage = messageParts[1]; // parse the message switch (messageType) { case "apply_filter": eqAPI.ApplyEqualizer((restOfMessage == "true") ? true : false); break; case "filter": if (restOfMessage == "added") { eqAPI.AddFilter(); } else if (restOfMessage == "removed") { eqAPI.RemoveFilter(); } break; case "filters": eqAPI.SetNewGainValues(restOfMessage.Split(new char[] { ',' })); break; case "playback": switch (restOfMessage) { case "pause": zuneAPI.PauseTrack(); break; case "play": zuneAPI.PlayTrack(); break; case "previous": zuneAPI.ToPreviousTrack(); break; case "next": zuneAPI.ToNextTrack(); break; } break; case "volume": eqAPI.PreAmp = Convert.ToInt32( Convert.ToDouble(restOfMessage)); break; } }