Esempio n. 1
0
 private void LoadNextAlbum()
 {
     while (true)
     {
         int i;
         lock (_filesToLoad)
         {
             i = _filesToLoad.Count;
         }
         if (i > 0)
         {
             AlbumArtWaiter waiter;
             lock (_filesToLoad)
             {
                 waiter = _filesToLoad.Dequeue();
             }
             waiter.IHaveAlbumArt.AlbumArt = AlbumArtHelper.GetAlbumArt(waiter.Filename, waiter.Width, waiter.Height);
         }
         else
         {
             _albumLoaderThread = null;
             Thread.CurrentThread.Abort();
         }
     }
 }
Esempio n. 2
0
        private void ProcessRequest(HttpRequest request)
        {
            string[] args = request.Url.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            if (args.Length > 0)
            {
                switch (args[0].ToLower())
                {
                case "lyrics":
                {
                    request.Response = @"<html>
                            <head>
                            <style>
                            body
                            { color:#FFFFEC; 
                                     vertical-align:top;
                                     margin:0px;
                                     padding:0px;
                                     border:0px;
                                     font-family:Verdana; 
                                     font-size:8pt; }
                            </style>
                            </head>
                            <body bgcolor=""#706F77"" text=""#FFFFEC"">" +
                                       (_lastLyrics == "Loading..." ? "<meta http-equiv=\"refresh\" content=\"5\">" : "") +
                                       _lastLyrics.Replace(Environment.NewLine, "<br />") + "</body></html>";
                    break;
                }

                case "albumart":
                {
                    if (_lastSong != _player.CurrentSong)
                    {
                        _lastSong = _player.CurrentSong;

                        _lastLyrics = "Loading...";

                        if (_library.GetSong(_lastSong.FileName) is LibraryEntry entry && !string.IsNullOrEmpty(entry.Lyrics))
                        {
                            _lastLyrics = entry.Lyrics;
                        }
                        else
                        {
                            _helper.LoadLyrics(_lastSong);
                        }

                        using (System.Drawing.Bitmap albumArt = AlbumArtHelper.GetAlbumArt(_lastSong.FileName, 200, 200))
                        {
                            using (var s = new MemoryStream())
                            {
                                albumArt.Save(s, System.Drawing.Imaging.ImageFormat.Jpeg);
                                byte[] b = s.ToArray();
                                _lastAlbumArt = System.Text.UnicodeEncoding.GetEncoding(0).GetString(b);
                            }
                        }
                    }

                    request.Headers.Add("Content-type", "image/jpeg");
                    request.Response = _lastAlbumArt;

                    break;
                }