示例#1
0
 private void app_OnPlayerPlayingTrackChangedEvent(object iTrack)
 {
     if (OnLogSong != null)
     {
         SongInfo si = new SongInfo(((IITTrack)iTrack).Artist, ((IITTrack)iTrack).Name, "iTunes");
         Console.WriteLine(si.Artist + " - " + si.Title);
         OnLogSong(si);
     }
 }
示例#2
0
        private void OnReceive(IAsyncResult ar)
        {
            try
            {
                Socket clientSocket = (Socket)ar.AsyncState;
                clientSocket.EndReceive(ar);

                ASCIIEncoding ascii = new ASCIIEncoding();

                string strCommand = ascii.GetString(byteData);
                strCommand = strCommand.Substring(0, strCommand.IndexOf('\r'));
                if (strCommand.Trim().Contains("GET /on"))
                {
                    if (OnResume != null)
                    {
                        OnResume();
                    }
                }
                else if (strCommand.Trim().Contains("GET /off"))
                {
                    if (OnPause != null)
                    {
                        OnPause();
                    }
                }
                else if (strCommand.Trim().Contains("GET /song?"))
                {
                    if (OnLogSong != null)
                    {
                        try
                        {
                            string strURL = strCommand.Trim().Substring(4);
                            strURL = strURL.Substring(0, strURL.IndexOf(' ')).Substring(6);
                            NameValueCollection nvc = HttpUtility.ParseQueryString(strURL);
                            SongInfo kte = new SongInfo(nvc["artist"], nvc["title"], nvc["source"]);
                            OnLogSong(kte);
                        }
                        catch (Exception ex)
                        {
                            PodcasterUtilities.KLIKException(ex);
                        }
                    }
                }
            #if DEBUG
                Console.WriteLine(strCommand);
            #endif

                clientSocket.Send(ascii.GetBytes("HTTP/1.1 200 OK\r\nDate: " +
                    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") +
                    "\r\nContent-Length: 0\r\nContent-type: text/plain\r\n\r\n"));
                clientSocket.Close();

            }
            catch (SocketException)
            {
            }
            catch (Exception ex)
            {
                PodcasterUtilities.KLIKException(ex);
            }
        }
示例#3
0
 /// <summary>
 /// Log a song played from the controller
 /// </summary>
 /// <param name="sp">Info on the song played</param>
 private void Controller_OnLogSong(SongInfo sp)
 {
     this.LogSong(new SongPlayed(this, DateTime.Now, sp));
 }