Exemple #1
0
        /// <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;
            }
        }
Exemple #2
0
 /// <summary>
 /// Handle a click event on the <see cref="button_next"/>.
 /// Causes the Zune player to move to the next track and the
 /// "track" enabler (<see cref="updateMessageEnabled"/>) to be set to true.
 /// </summary>
 /// <param name="sender">N/A</param>
 /// <param name="e">N/A</param>
 private void button_next_Click(object sender, EventArgs e)
 {
     updateMessagesEnabled["track"] = true;
     zuneAPI.ToNextTrack();
 }