Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==PREPROCESSOR==
- // @name "Album art display"
- // @author "D. Gjorgjevski"
- // ==/PREPROCESSOR==
- window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 325;
- var coverImage = null;
- var defaultFont = gdi.Font(window.GetFontDUI(0).Name, 18); // Default font, size 18
- function on_paint(graphics)
- {
- graphics.SetSmoothingMode(4); // Use anti-aliasing
- graphics.FillSolidRect(0, 0, window.Width, window.Height, 0xFFFFFFFF); // Fill the background
- if (coverImage)
- {
- graphics.SetInterpolationMode(7); // Use high-quality bicubic interpolation
- graphics.DrawImage(coverImage, 0, 0, window.Width, window.Height, 0, 0, coverImage.Width, coverImage.Height);
- }
- else
- {
- graphics.SetTextRenderingHint(4); // Use anti-aliased text
- graphics.GdiDrawText("No image was found to be displayed.", defaultFont, 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, type, image, path)
- {
- coverImage = image;
- window.Repaint();
- }
- function on_playback_new_track(whichTrack)
- {
- if (whichTrack)
- utils.GetAlbumArtAsync(window.ID, whichTrack, 0, false, false, false);
- /*
- 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.
- */
- coverImage && coverImage.Dispose();
- }
- on_playback_new_track(fb.GetNowPlaying());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement