Example #1
0
        ///<summary>
        ///This is where the magic happens. Fired on track change
        ///</summary>
        public void TrackChanged(TrackPlayer Player)
        {
            //Check if the plugin is enabled (We trust you to have the config done properly)
            //AND
            //Current Track's type is part of the user-selected Track types
            if (Enabled && (SelectedTrackTypes.Length == 0 || Array.Exists(SelectedTrackTypes, delegate(string s) { return(s.Equals(Player.TrackData.TrackType.ToString())); })))
            {
                //increase counter for PlayCount Timing (if we're on "Time" timing, this won't hurt either. Worst that could happen is the number overflowing)
                counter++;
                //compare NOW and startTime + Interval minutes
                int compareTimes = DateTime.Compare(DateTime.Now, startTimer.AddMinutes(Interval));

                //Send a message if PlayCount counter is greater than the interval
                if (Timing == "WaitForPlayCount" && counter > Interval)
                {
                    //Disable Plugin if the webservice reports a problem
                    if (!Requester.SendRequest(this, Player.TrackData, Message, Networks, UserId, Password, SendCoverArt))
                    {
                        Enabled = false;
                    }
                    //reset counter
                    counter = 0;
                }
                //Send message if "Time" comparison results in the NOW time being greater than the base time + interval
                else if (Timing == "WaitForTime" && compareTimes >= 0)
                {
                    //Disable Plugin if the webservice reports a problem
                    if (!Requester.SendRequest(this, Player.TrackData, Message, Networks, UserId, Password, SendCoverArt))
                    {
                        Enabled = false;
                    }
                    //reset base time
                    startTimer = DateTime.Now;
                    //reset counter to prevent integer overflow
                    counter = 0;
                }
            }
        }