Konfig Problem mit WSH Panel Mod

Begonnen von mexx, 02. November 2023, 12:33:18

Vorheriges Thema - Nächstes Thema

mexx

Ich habe folgende Konfiguration zur Anzeige eines Bildes für den Codec des gespielten Files:

function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }

var imgPath = fb.FoobarPath + "images\\";
var rat0 = gdi.Image(imgPath + "mp3.jpg");
var rat1 = gdi.Image(imgPath + "AAC.jpg");
var rat2 = gdi.Image(imgPath + "vorbis.jpg");

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

function Rating (x,y,w,h){
var star = fb.TitleFormat("%codec%");

this.draw = function (gr) {
if(star.eval()==1) gr.DrawImage(rat0, 0, 0, window.Width, window.Height, 0, 0, 700, 700);
    else {if(star.eval()==2) gr.DrawImage(rat1, 0, 0, window.Width, window.Height, 0, 0, 700, 700);
              else {if(star.eval()==3) gr.DrawImage(rat2, 0, 0, window.Width, window.Height, 0, 0, 700, 700);
                      else {if(star.eval()==3) gr.DrawImage(rat3, 0, 0, window.Width, window.Height, 0, 0, 700, 700);
                                else {if(star.eval()==4) gr.DrawImage(rat4, 0, 0, window.Width, window.Height, 0, 0, 700, 700);
                                          else {if(star.eval()==5) gr.DrawImage(rat5, 0, 0, window.Width, window.Height, 0, 0, 700, 700);
else gr.DrawImage(rat0, 0, 0, window.Width, window.Height, 0, 0, 700, 700);
}}}}}
}
}

function on_paint(gr){
rating.draw(gr);
}

function on_size(){
ww = window.Width;
wh = window.Height;
rating = new Rating(0,0,ww,wh);
}


function on_playback_new_track(metadb) {
window.Repaint();
}

//EOF

Das Bild wird auch angezeigt, aber immer nur das Bild 1 (mp3). Es erfolgt kein Bildwechsel bei Codecwechsel.

Ich kenn mich nicht gut genug mit dem Konfigurieren aus. daher bitte ich um Hilfe bei der Fehlersuche.

mexx

OK...habs selbst über JScript Panel hinbekommen:

var cfg_foobarpath = window.GetProperty("foobar path:", fb.Profilepath);
var cfg_codec = window.GetProperty("i folder:", "images");
var svg_file = cfg_foobarpath + cfg_codec + "\\nocodec.svg";
var svg_content = utils.ReadUTF8(svg_file);

var dui = window.IsDefaultUI;

var original = utils.LoadSVG(svg_file);

function on_paint(gr) {
    gr.FillRectangle(0, 0, window.Width, window.Height, dui == 1 ? window.GetColourDUI(1) : window.GetColourCUI(3)); 
    if (original) {
        var scale = 0;
        var x = 0,
            y = 0;
        var scale_w = window.Width / original.Width;
        var scale_h = window.Height / original.Height;

        if (scale_w <= scale_h) {
            scale = scale_w;
            y = (window.Height - original.Height * scale) / 2;
        } else {
            scale = scale_h;
            x = (window.Width - original.Width * scale) / 2;
        }
        gr.DrawImage(original, 0, 0, window.Width, window.Height, 0, 0, original.Width, original.Height);
    }
}

if(fb.IsPlaying || fb.IsPaused) {
    codec = fb.TitleFormat("%codec%").Eval();
    original = utils.LoadSVG(cfg_foobarpath + cfg_codec + "\\" + codec + ".svg");
    window.Repaint(); 
}
else {
    original = utils.LoadSVG(svg_file);
    window.Repaint();
}

function on_playback_new_track() {
    codec = fb.TitleFormat("%codec%").Eval();
    original = utils.LoadSVG(cfg_foobarpath + cfg_codec + "\\" + codec + ".svg");
    window.Repaint();
}

function on_playback_stop(reason) {
    original = utils.LoadSVG(svg_file);
    window.Repaint();
}