Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: WSH Panel Mod script discussion/help (Read 1405428 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #850
seems to be working ok here. perhaps a temporary glitch at the last.fm end? and have you checked art definitely exists for the artist by visiting the page?

as for your PM request, i've updated the "now playing" script so you can turn off the front cover display via the context menu,

http://cid-649d3bfeaf541fbb.office.live.co...ide/samples.zip


Thanks! Maybe I broke something when tinkering with your script, I'll try the update.

WSH Panel Mod script discussion/help

Reply #851
Hmmm.... still not working after playing 4 songs for the same artist.  My settings are:

Last.fm Options: Automatically Download (check)
                        Limit: 20
                        Blacklist Deleted Images (check)

Cycle: 20 seconds

Font Cover Display: Off












I have edited things in the script (from lines 7-16), but I don't think it should make a difference:



Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common.js"
// @name "Now Playing"
// @author "marc2003"
// ==/PREPROCESSOR==

var stopped_text = "foobar2000";
var title_tf =  fb.TitleFormat("[%discnumber%.]%tracknumber%'/'[%discnumber%.]%totaltracks% - %title%");
var album_tf = fb.TitleFormat("[%artist%]");
var artist_tf = fb.TitleFormat("$ifequal([%LASTFM_LOVED%],1,♥,)");
var title_font = gdi.Font("Segoe UI", 28, 1);
var album_font = gdi.Font("Segoe UI", 22, 1);
var artist_font = gdi.Font("Segoe UI", 22, 1);
var title_colour = RGB(40,179,255);
var album_colour = RGB(210, 210, 210);
var artist_colour = RGB(255,0,0);
var blacklist_file = '';
var title = '';
var artist = '';
var album = '';
var foobar_img = gdi.Image(images_path + "new foo.png");

var album_img = null;
var artist_img = null;
var arr = new Array();
var g_valid_tid = 0;

window.GetProperty("bl", true);
window.GetProperty("auto", true);
var cycle = window.GetProperty("cycle", 200) - 200;
var limit = window.GetProperty("limit", 305) - 300;
var album_img_size = window.GetProperty("album_img_size", 510) - 400;

if(fb.IsPlaying) on_playback_new_track();

function on_playback_time(time) {
    if(cycle > 0 && arr.length > 1 && (time % cycle == 0)) on_mouse_wheel(-1);
}

function on_playback_stop(reason) {
    album_img && album_img.Dispose();
    artist_img && artist_img.Dispose();
    g_metadb = album_img = artist_img = arr = null;
    if(reason != 2) window.Repaint();
}

function  on_playback_new_track() {
    g_metadb = fb.GetNowPlaying();
    artist = artist_tf.EvalWithMetadb(g_metadb);
    title = title_tf.EvalWithMetadb(g_metadb);
    album = album_tf.EvalWithMetadb(g_metadb);
    album_img && album_img.Dispose();
    album_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, 0);
    if(!album_img) utils.GetAlbumArtAsync(window.ID, g_metadb, 0);
    folder = data_folder + fb.TitleFormat("$crc32(%artist%)").EvalWithMetadb(g_metadb);
    bl();
    arr = read_images();
    if(arr.length == 0 && window.GetProperty("auto")) {
        download_images();
    } else {
        index = Math.floor(Math.random()*arr.length);
        load_image();
    }
}

function on_mouse_wheel(delta) {
    if(!g_metadb || arr.length < 2) return;
    index += -delta;
    if(index < 0) index = arr.length - 1;
    if(index >= arr.length) index = 0;
    load_image();
}

function load_image() {
    artist_image_path = arr[index];
    g_valid_tid = gdi.LoadImageAsync(window.ID, artist_image_path);
}

function on_load_image_done(tid, image) {
    if (g_valid_tid == tid) {
        artist_img && artist_img.Dispose();
        artist_img = image;
        window.Repaint();
    }
}

function on_mouse_lbtn_dblclk() {
    try {WshShell.Run("\"" + artist_image_path + "\""); } catch(e) {}
}

function on_get_album_art_done(metadb, art_id, im, ip) {
    album_img = im;
    window.Repaint();
}

function on_size() {
    ww = window.width;
    wh = window.height;
}

function on_paint(gr) {
    gr.SetInterpolationMode(6);
    if(artist_img) {
        scale(gr, artist_img, 0, 0, ww, wh, "max");
    } else {
        gr.FillGradRect(0, 0, ww, wh, 90,g_backcolor, g_textcolor_hl);
    }
    gr.FillSolidRect(0,wh-130,ww,110,RGBA(0,0,0,156));
    if(album_img && album_img_size > 0) {
        text_x = album_img_size + 10;
        scale(gr, album_img, 0, wh-20-album_img_size, album_img_size, album_img_size, "min");
    } else {
        text_x = 10;
    }
    if(fb.IsPlaying) {
        gr.GdiDrawText(title, title_font, title_colour, text_x, wh -127, ww-text_x-10, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
        gr.GdiDrawText(album, album_font, album_colour, text_x, wh - 80, ww-text_x-10, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
        gr.GdiDrawText(artist, artist_font, artist_colour, text_x, wh - 55, ww-text_x-10, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
    } else {
        scale(gr, foobar_img, 0, 0, ww, wh - 130, "min");
        gr.GdiDrawText(stopped_text, title_font, title_colour, 0, wh - 130, ww, 110,DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
    }
}

function on_mouse_rbtn_up(x, y) {
    var _album = window.CreatePopupMenu();
    var _cycle = window.CreatePopupMenu();
    var _menu = window.CreatePopupMenu();
    var _lastfm_options = window.CreatePopupMenu();
    var _limit = window.CreatePopupMenu();
    var idx;
    _menu.AppendMenuItem(g_metadb ? MF_STRING : MF_GRAYED, 11, "Download artist art from Last.fm");
    _lastfm_options.AppendMenuItem(MF_STRING, 1000, "Automatically download");
    _lastfm_options.CheckMenuItem(1000, window.GetProperty("auto"));
    _limit.AppendMenuItem(MF_STRING, 301, "1");
    _limit.AppendMenuItem(MF_STRING, 303, "3");
    _limit.AppendMenuItem(MF_STRING, 305, "5");
    _limit.AppendMenuItem(MF_STRING, 310, "10");
    _limit.AppendMenuItem(MF_STRING, 320, "20");
    _limit.CheckMenuRadioItem(301, 320, window.GetProperty("limit"));
    _lastfm_options.AppendMenuItem(MF_STRING | MF_POPUP, _limit.ID, "Limit");
    _lastfm_options.AppendMenuItem(MF_SEPARATOR, 0, 0);
    _lastfm_options.AppendMenuItem(MF_STRING, 1001, "Blacklist deleted images");
    _lastfm_options.CheckMenuItem(1001, window.GetProperty("bl"));
    _lastfm_options.AppendMenuItem(fso.FileExists(blacklist_file) ? MF_STRING : MF_GRAYED, 1002, "Clear blacklist for this artist");
    _lastfm_options.AppendMenuItem(MF_SEPARATOR, 0, 0);
    _lastfm_options.AppendMenuItem(MF_STRING, 1003, "Explain blacklisting");
    _menu.AppendMenuItem(MF_STRING | MF_POPUP, _lastfm_options.ID, "Last.fm options");
    _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
    _cycle.AppendMenuItem(MF_STRING, 200, "Off");
    _cycle.AppendMenuItem(MF_STRING, 205, "5 seconds");
    _cycle.AppendMenuItem(MF_STRING, 210, "10 seconds");
    _cycle.AppendMenuItem(MF_STRING, 220, "20 seconds");
    _cycle.CheckMenuRadioItem(200, 220, window.GetProperty("cycle"));
    _menu.AppendMenuItem(MF_STRING | MF_POPUP, _cycle.ID, "Cycle");
    _album.AppendMenuItem(MF_STRING, 400, "Off");
    _album.AppendMenuItem(MF_STRING, 510, "Small");
    _album.AppendMenuItem(MF_STRING, 620, "Large");
    _album.CheckMenuRadioItem(400, 620, window.GetProperty("album_img_size"));
    _menu.AppendMenuItem(MF_STRING | MF_POPUP, _album.ID, "Front cover display");
    _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
    _menu.AppendMenuItem(artist_img ? MF_STRING : MF_GRAYED, 12, "Open containing folder");
    if(artist_img) _menu.AppendMenuItem(MF_STRING, 15, "Delete this image");
    _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
    if(utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 99, "Properties");
    _menu.AppendMenuItem(MF_STRING, 100, "Configure...");
    idx = _menu.TrackPopupMenu(x, y);
    switch(idx) {
        case 200:
        case 205:
        case 210:
        case 220:
            window.SetProperty("cycle", idx);
            cycle = idx - 200;
            break;
        case 301:
        case 303:
        case 305:
        case 310:
        case 320:
            window.SetProperty("limit", idx);
            limit = idx - 300;
            break;
        case 400:
        case 510:
        case 620:
            window.SetProperty("album_img_size", idx);
            album_img_size = idx - 400;
            window.Repaint();
            break;
        case 11:
            download_images();
            break;
        case 12:
            WshShell.Run("explorer /select," + artist_image_path);
            break;
        case 15:
            try {
                if(window.GetProperty("bl") == true) {
                    ts = fso.OpenTextFile(blacklist_file, 2, true, -1);
                    ts.WriteLine(blacklist + arr[index] + "|");
                    ts.close();
                }
                artist_img.Dispose();
                artist_img = null;
                fso.DeleteFile(arr[index]);
            } catch(e) {
                fb.trace("Error: Could not delete " + arr[index]);
            }
            on_playback_new_track();
            break;
        case 99:
            window.ShowProperties();
            break;
        case 100:
            window.ShowConfigure();
            break;
        case 1000:
            window.SetProperty("auto", !window.GetProperty("auto"));
            break;
        case 1001:
            window.SetProperty("bl", !window.GetProperty("bl"));
            break;
        case 1002:
            try { fso.DeleteFile(blacklist_file); } catch(e) {}
            break;
        case 1003:
            fb.ShowPopupMessage("When you delete an image, there is no way for this script to prevent it being downloaded again. As a workaround, you can \"blacklist\" images you don't want and they will be deleted after downloading is complete.", "Now Playing");
            break;
    }
    _lastfm_options.Dispose();
    _menu.Dispose();
    _cycle.Dispose();
    _limit.Dispose();
    _album.Dispose();
    return true;
}


WSH Panel Mod script discussion/help

Reply #852
After finally realizing the power and usability of this component thanks to marc2003's samples I decided to start with a small customizable Now Playing script to get my feet wet.
The script is available here : http://dl.dropbox.com/u/3317443/wsh_now_playing_scroll.txt
Sample usage (the panel marked out in red):
Also, I'm having trouble displaying dynamic bitrate. Any suggestions? I've tried reloading g_metadb through the on_playback_dynamic)info callback to no avail.

WSH Panel Mod script discussion/help

Reply #853
@Fractal_Mortality

ah you can't edit "artist_tf" like that. what it displays is also used to query last.fm

edit: i've updated it so the display is completely independent of what is sent to last.fm. you can now change those fields as you like.

http://cid-649d3bfeaf541fbb.office.live.co...ide/samples.zip

WSH Panel Mod script discussion/help

Reply #854
@Fractal_Mortality

ah you can't edit "artist_tf" like that. what it displays is also used to query last.fm

edit: i've updated it so the display is completely independent of what is sent to last.fm. you can now change those fields as you like.

http://cid-649d3bfeaf541fbb.office.live.co...ide/samples.zip


You are the man. I'll try this when I get home.

WSH Panel Mod script discussion/help

Reply #855
Also, I'm having trouble displaying dynamic bitrate. Any suggestions? I've tried reloading g_metadb through the on_playback_dynamic)info callback to no avail.


something like this....

Code: [Select]
function on_playback_dynamic_info() {
    bitrate = fb.TitleFormat("%bitrate% kbps").Eval();
    window.Repaint();
}

WSH Panel Mod script discussion/help

Reply #856
Thanks ^.^

I'm modifying your last.fm charts sample now for use with artist top tracks and albums, excellent sample. More and more I find my config being overtaken by wsh panels.

WSH Panel Mod script discussion/help

Reply #857
marc2003, I've been looking at the Last.fm webservices and I'm interested in creating a script that downloads the album art as denoted by the 'image size="large"' tag in the album.getInfo method. I was assuming your artist art downloader script performs a similar service and your art.exe could be used to download the album art as well, but I can see that its use is limited to artist art. Can you direct me to the tools I would need to create the album art downloader script (or perhaps merely to a similar already existing script)?

I guess if there's no other feasible option I could simply provide the url for the album art in the panel.

WSH Panel Mod script discussion/help

Reply #858
it is actually possible to download images directly using WSH panel mod.

http://www.hydrogenaudio.org/forums/index....mp;#entry680952

but as i was already happily using art.exe, i saw no reason to change. after all, it's only a few kb in size.

i didn't make the art.exe program. that was made by another forum member, paradog.

http://www.hydrogenaudio.org/forums/index....c=77425&hl=

thanks to him for providing the source code - i had to modify it slightly so it runs silently without any user intervention. and that's why i've bundled my changed source code with the .exe - i'm hopefully complying with the terms of the original license.

it's made in c# and can be modified/compiled using visual studio c# express edition. it's free but a fairly hefty download and it does install a fair amount of crap.

WSH Panel Mod script discussion/help

Reply #859
Thanks again! That piece of code works beautifully. The only problem is that the script locks up foobar while it downloads the file, a minor price to pay but is there a way to avoid this? Or possibly I'm doing something wrong?

The script: http://dl.dropbox.com/u/3317443/wsh_now_pl..._lastfm_art.txt

WSH Panel Mod script discussion/help

Reply #860
if you read that post again, the person who orginally made that snippet has the same issue. i wouldn't know if there is any way around it.

but it should be fairly trivial to modify the art.exe program. i'll have a look later on.

WSH Panel Mod script discussion/help

Reply #861
Oh... well, if you can make that modification to art.exe it would awesome. Otherwise, the way I have it setup right now I've bound the download to a click action so I can at least decide when to download the art and be ready for the freeze. Again, a very minor price to pay.

WSH Panel Mod script discussion/help

Reply #862
it took more effort than i expected. also, i don't know proper programming so it's a real hack job. it works though...

it takes 4 arguments

<artist> <album> <path> <filename with no extension>

eg

Code: [Select]
album.exe "Bat For Lashes" "Fur And Gold" "c:\music\bat for lashes\fur and gold" "folder"


it would then save as folder.jpg or folder.png depending on what it finds.

http://cid-649d3bfeaf541fbb.office.live.co...guide/album.zip

WSH Panel Mod script discussion/help

Reply #863
Thanks a lot. That does the job perfectly  I'm still keeping the last.fm webservices code I was using earlier as an option so I can download the mega version of some art if I want to, also my earlier script gives me an indication as to whether album.exe will find anything at last.fm or not.

WSH Panel Mod script discussion/help

Reply #864
it already downloads the "mega" image. with the few albums i tested, they aren't very big anyway.

WSH Panel Mod script discussion/help

Reply #865
Hah I was just about to edit my post to indicate that I meant large (300x300) and not mega  I try and avoid the really huge album arts because they make my np script cpu heavy when repainting the panel with huge images.

Also, is there a way to export embedded album art via this panel? Like open it in an image object and write it to a file. I was looking through activexobjects, but couldn't find a solution.

WSH Panel Mod script discussion/help

Reply #866
i should be able to make it accept the size as an another argument on the commandline.

WSH Panel Mod script discussion/help

Reply #867
That would be great. Hope it's not too much trouble.

WSH Panel Mod script discussion/help

Reply #868
done. same link as above. now takes 5 arguments with size being the last one.

WSH Panel Mod script discussion/help

Reply #869
Nice. I peeked into the fetchArt.cs too, looks good 

WSH Panel Mod script discussion/help

Reply #870
I have a small Request, I would like a script that  shows recently played from Last.FM and if possible
a link to the last.FM page of the song.
If this is possible would you mind writing the script ?

Thanks in advance.

WSH Panel Mod script discussion/help

Reply #871
How can I make an image appear for a second? I have a panel that displays album art and now playing details and I have some basic gesture controls togo to next track, previous track, volume up, and volume down and I want an image to appear when one of these gestures is completed.
Here's my current (sloppy) code:
Code: [Select]
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
function RGBA(r, g, b, a) {return ((a << 24) | (r << 16) | (g << 8) | (b));}

var artist = fb.TitleFormat("$abbr(%artist%,19)");
var title = fb.TitleFormat("$abbr(%title%,19)");
var album = fb.TitleFormat("$abbr(%album%,19)");
var codec = fb.TitleFormat("%codec% $if($strcmp(%codec%,'MP3'),%codec_profile%)");
var bitrate = fb.TitleFormat("%bitrate%");
var playcount = fb.TitleFormat("%play_count%");
var ww=window.Width;
var wh=window.Height;
var col = RGB(255, 255, 255);
var col1 = RGB(255,0,0);
var col2 = RGB(255,128,0);
var col3 = RGB(255,255,0);
var col4 = RGB(0,255,0);
var hoffset = 4;
var paused;
var btndwn;
var x1;
var y1;

function on_item_played(metadb) {window.Repaint();}
function on_playback_edited(metadb) {window.Repaint();}


function get_album_art(metadb) {
    if (metadb)
        return utils.GetAlbumArt(metadb.RawPath, 0);
}

function on_mouse_lbtn_down(x, y, mask){
    btndwn = true;
    x1 = x;
    y1 = y;
}

function on_mouse_lbtn_up(x, y, mask){
    if (btndwn){
        var tlrnce = 10;
        btndwn = false;
        if ( (x>x1 + tlrnce) && (y < y1 + tlrnce) && (y > y1 - tlrnce) ){
            fb.Next();
        }
        if ( (x<x1 - tlrnce) && (y < y1 + tlrnce) && (y > y1 - tlrnce) ){
            fb.Prev();
        }
        if ( (y<y1-tlrnce) && (x < x1 + tlrnce) && (x > x1 - tlrnce) ){
            fb.VolumeUp();
            fb.VolumeUp();
        }
        if ( (y>y1+tlrnce) && (x < x1 + tlrnce) && (x > x1 - tlrnce) ){
            fb.VolumeDown();
            fb.VolumeDown();
        }
        window.Repaint();
    }
}

var g_img = null;

on_playback_new_track(fb.GetNowPlaying());

function on_paint(gr) {
    gr.FillSolidRect(0,0,ww,wh,RGB(96,96,96));
    var font = gdi.Font("Verdana", 15, 1);
    var spacing = 15;
    var voffset = 4;
    var img_size;
    if(wh-spacing*6+10>ww){
        img_size=ww;
    }else{
        img_size=wh-spacing*6+10;
    }
    if (g_img) {
        gr.SetInterpolationMode(7); // Highest quality and also slowest
        gr.DrawImage(g_img, 0, spacing*6+10, img_size, img_size, 0, 0, g_img.Width, g_img.Height);
    }
    if (paused){gr.DrawImage(gdi.image( fb.FoobarPath+"Images\\pause.png"), 0, spacing*6+10, img_size, img_size, 0, 0, 500, 500,0,255);}
    if (fb.IsPlaying){
        gr.GdiDrawText(artist.Eval()+"&", font, col, hoffset, voffset, ww, wh);
        gr.GdiDrawText(title.Eval(), font, col, hoffset, voffset+spacing, ww, wh);
        gr.GdiDrawText(album.Eval(), font, col, hoffset, voffset+2*spacing, ww, wh);
        gr.GdiDrawText(codec.Eval(), font, col, hoffset, voffset+3*spacing, ww, wh);
        if(bitrate.Eval()<=128){
            gr.GdiDrawText(bitrate.Eval(), font, col1, hoffset, voffset+4*spacing, ww, wh);
        }else{
            if(bitrate.Eval()<=192){
                gr.GdiDrawText(bitrate.Eval()+" kbps", font, col2, hoffset, voffset+4*spacing, ww, wh);
            }else{
                if(bitrate.Eval()<320){
                    gr.GdiDrawText(bitrate.Eval()+" kbps", font, col3, hoffset, voffset+4*spacing, ww, wh);
                }else{
                    gr.GdiDrawText(bitrate.Eval()+" kbps", font, col4, hoffset, voffset+4*spacing, ww, wh);
                }
            }
        }

        if(playcount.Eval()==0){
            gr.GdiDrawText("Never played", font, col, hoffset, voffset+5*spacing, ww, wh);
        }else{
            if(playcount.Eval()==1){
                gr.GdiDrawText("Played once", font, col, hoffset, voffset+5*spacing, ww, wh);
            }else{
                if(playcount.Eval()==2){
                    gr.GdiDrawText("Played twice", font, col, hoffset, voffset+5*spacing, ww, wh);
                }else{
                    gr.GdiDrawText("Played "+playcount.Eval()+" times", font, col, hoffset, voffset+5*spacing, ww, wh);
                }
            }
        }
    }else{
        gr.DrawImage(gdi.image( fb.FoobarPath+"Images\\foobar.png"), 0, spacing*6+10, img_size, img_size, 0, 0, 500, 500);
    }
}

function on_mouse_lbtn_dblclk(x, y, mask){
    if (y>100)
        fb.Pause();
    }

function on_playback_pause(state){
    paused=state;
    window.Repaint();
}

function on_playback_time(time){
    window.Repaint();
}


function on_size() {
    ww = window.Width;
    wh = window.Height;
}

function on_playback_new_track(metadb) {
    if (!metadb) return;
    paused=false;
    g_img = get_album_art(metadb);
    window.Repaint();    
}

function on_playback_stop(reason){
    g_img=gdi.image( fb.FoobarPath+"Images\\foobar.png");
    paused=false;
    window.Repaint();
}


Also great thread I've learned a lot by looking at your codes so thanks a lot to everyone that posted here! And I apologize if anyone already answered this question I searched around for a bit but I didn't find an explanation on how to do it.

WSH Panel Mod script discussion/help

Reply #872
I updated my scripts recently using the latest samples.zip on you Windows Live space. I am getting some odd results with the last.fm simple biography script.

Some artists the biography appears fine and all text is visible and I am able to scroll up and down. Other artists only 2 or 3 lines appear followed by ... although there is plenty of space in the window for the remaining text. If I make the WSH panel wider then some of the text appears.




WSH Panel Mod script discussion/help

Reply #873
Is there a sample on how to create something which you can drag? i.e. images or text.
<3 f00

 

WSH Panel Mod script discussion/help

Reply #874
@djphatic... and you haven't modified the script at all? i find it hard to believe that would happen with my original. 

)[/size]

also, right click the panel and hit update. that will force it to download the page from last.fm again (but i really don't think that could be an issue either?????  )