Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==PREPROCESSOR==
- // @name "Album art display"
- // ==/PREPROCESSOR==
- window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 333;
- var Artwork =
- {
- Image: null,
- Path: ""
- }
- var Info =
- {
- Tooltip: window.CreateTooltip(),
- Active: false
- }
- function on_paint(graphics)
- {
- graphics.SetSmoothingMode(4); // Use anti-aliasing
- graphics.FillSolidRect(0, 0, window.Width, window.Height, 0xFFFFFFFF); // Fill the background
- if (Artwork.Image)
- {
- graphics.SetInterpolationMode(7); // Use high-quality bicubic interpolation
- graphics.DrawImage(Artwork.Image, 0, 0, window.Width, window.Height, 0, 0, Artwork.Image.Width, Artwork.Image.Height);
- if (Info.Active)
- {
- Info.Tooltip.Deactivate();
- Info.Tooltip.Text = "Original size: " + Artwork.Image.Width + "×" + Artwork.Image.Height + " pixels.";
- Info.Tooltip.Activate();
- }
- else
- {
- Info.Tooltip.Text = "Original size: " + Artwork.Image.Width + "×" + Artwork.Image.Height + " pixels.";
- }
- }
- else
- {
- graphics.SetTextRenderingHint(4); // Use anti-aliased text
- graphics.GdiDrawText("No image was found to be displayed.", gdi.Font(window.GetFontDUI(0).Name, 19), 0x00000000, 0, 0, window.Width, window.Height, 3077);
- }
- /*
- DT_CENTER = 0x00000001
- DT_VCENTER = 0x00000004
- DT_CALCRECT = 0x00000400
- DT_NOPREFIX = 0x00000800
- DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX = 3077
- */
- }
- function on_get_album_art_done(whichTrack, coverType, coverImage, coverPath)
- {
- if (coverPath != Artwork.Path)
- {
- Artwork.Image && Artwork.Image.Dispose();
- Artwork.Image = coverImage;
- Artwork.Path = coverPath;
- window.Repaint();
- }
- }
- function on_playback_new_track(whichTrack)
- {
- if (whichTrack)
- {
- utils.GetAlbumArtAsync(window.ID, whichTrack, 0, false, false, false);
- whichTrack.Dispose();
- }
- /*
- Do not load a stub image if no cover art is found.
- Check for external as well as for embedded images.
- Load the image into the memory and use it within the callback.
- */
- }
- function on_mouse_move(x, y)
- {
- if (!Info.Active && Artwork.Image)
- {
- Info.Tooltip.Activate();
- Info.Active = true;
- }
- }
- function on_mouse_leave()
- {
- if (Info.Active)
- {
- Info.Tooltip.Deactivate();
- Info.Active = false;
- }
- }
- on_playback_new_track(fb.GetNowPlaying());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement