Advertisement
Guest User

Artwork viewer

a guest
Nov 4th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==PREPROCESSOR==
  2. // @name "Album art display"
  3. // @author "D. Gjorgjevski"
  4. // ==/PREPROCESSOR==
  5.  
  6. window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 325;
  7.  
  8. var coverImage = null;
  9. var defaultFont = gdi.Font(window.GetFontDUI(0).Name, 18); // Default font, size 18
  10.  
  11. function on_paint(graphics)
  12. {
  13.     graphics.SetSmoothingMode(4); // Use anti-aliasing
  14.     graphics.FillSolidRect(0, 0, window.Width, window.Height, 0xFFFFFFFF); // Fill the background
  15.    
  16.     if (coverImage)
  17.     {
  18.         graphics.SetInterpolationMode(7); // Use high-quality bicubic interpolation
  19.         graphics.DrawImage(coverImage, 0, 0, window.Width, window.Height, 0, 0, coverImage.Width, coverImage.Height);
  20.     }
  21.     else
  22.     {
  23.         graphics.SetTextRenderingHint(4); // Use anti-aliased text
  24.         graphics.GdiDrawText("No image was found to be displayed.", defaultFont, 0x00000000, 0, 0, window.Width, window.Height, 3077);
  25.     }
  26.    
  27.     /*
  28.         DT_CENTER   = 0x00000001
  29.         DT_VCENTER  = 0x00000004
  30.         DT_CALCRECT = 0x00000400
  31.         DT_NOPREFIX = 0x00000800
  32.        
  33.         DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX = 3077
  34.     */
  35. }
  36.  
  37. function on_get_album_art_done(whichTrack, type, image, path)
  38. {
  39.     coverImage = image;
  40.     window.Repaint();
  41. }
  42.  
  43. function on_playback_new_track(whichTrack)
  44. {
  45.     if (whichTrack)
  46.         utils.GetAlbumArtAsync(window.ID, whichTrack, 0, false, false, false);
  47.        
  48.     /*
  49.         Do not load a stub image if no cover art is found.
  50.         Check for external as well as for embedded images.
  51.         Load the image into the memory and use it within the callback.
  52.     */
  53.    
  54.     coverImage && coverImage.Dispose();
  55. }
  56.  
  57. on_playback_new_track(fb.GetNowPlaying());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement