Skip to main content

Topic: WSH Panel Mod script discussion/help (Read 839334 times) previous topic - next topic

0 Members and 2 Guests are viewing this topic.
  • Rarn
  • [*]
WSH Panel Mod script discussion/help
Reply #2500
Well, I've found a solution if anybody else turns out to be curious, no thanks to me, but to finding the necessary code in a coverflow panel by "Br3tt aka Falstaff." 

It used this function (very slightly modified to remove dependencies):
Code: [Select]
function ShowNowPlaying() {
    if(fb.IsPlaying) {
        if(plman.PlaylistItemCount(plman.PlayingPlaylist)==0) {
            return true;
        };
        plman.ClearPlaylistSelection(plman.PlayingPlaylist);
        var nowplaying = plman.GetPlayingItemLocation();
        var pid = nowplaying.PlaylistItemIndex;
        if(pid>=0 && pid<plman.PlaylistItemCount(plman.PlayingPlaylist)) {
            plman.SetPlaylistFocusItem(plman.PlayingPlaylist, pid);
            plman.SetPlaylistSelectionSingle(plman.PlayingPlaylist, pid, true);
            plman.ActivePlaylist = plman.PlayingPlaylist;
        };
    } else {
        if(plman.PlaylistItemCount(plman.ActivePlaylist)==0 || !fb.GetFocusItem(false)) return true;
        plman.ClearPlaylistSelection(plman.ActivePlaylist);
        var pid = plman.GetPlaylistFocusItemIndex(plman.ActivePlaylist);
        plman.SetPlaylistFocusItem(plman.ActivePlaylist, pid);
        plman.SetPlaylistSelectionSingle(plman.ActivePlaylist, pid, true);
    };
};


I'm not sure what the purpose of the code in the else statement is though, it appears to behave the same without it.

WSH Panel Mod script discussion/help
Reply #2501
when I last worked on my foobar config, WSH panel was just released... and turns out I completely underestimated the potential of this component. What you guys accomplished is beyond amazing

@Marc2003:
I am just trying to adapt some of your great panels for my config, and I stumbled upon a small issue concering the last.fm panel (and similar) when using "Selection Mode / Use Display Preferences" (set to "prefer current selection" in Preferences):
When I select a group in el_playlist by clicking on the group header, the panels switch back to the now playing artist for a very brief moment. Only happens during playback/pause, its fine while stopped.
Some function (item_focus_change() I think) is triggered twice, probably because el_playlist clears the selection before making a new one, or something like that.

I tried fixing it myself by adding a tiny delay time in various parts of the script, without success (obviously...). I'm afraid this is to difficult for me, just having started with WSH panel and having next to no JScript experience 

Anyways, thanks for those awesome scripts
  • Last Edit: 26 July, 2013, 01:11:53 PM by SardonicWrath

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2502
i can't seem to reproduce that issue but i know the selection can change back to now playing when the playlist loses focus. i guess you're seeing this.

instead you can right click panel>selection mode>follow selected track. that should always stay with selection even when the playlist loses focus.

  • Bratman
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2503
That album background camouflage effect is cool I always wished this was possible with channel spectrum so the spectrum bars changed colour with the album art above.

WSH Panel Mod script discussion/help
Reply #2504
i can't seem to reproduce that issue but i know the selection can change back to now playing when the playlist loses focus. i guess you're seeing this.

instead you can right click panel>selection mode>follow selected track. that should always stay with selection even when the playlist loses focus.

well, thats probably because I have a kind of unusual setup... I use two playlists that are visible all the time, one for playback and one for viewing the library. The playback one is always kept active (I use a script for that).
"Follow selected track" doesn't work well for that, it sticks to one playlist
Still a bit confused how all of this works, with focused/selected items/playlists....

Anyway, I found a solution:
Code: [Select]
function on_selection_changed() {
    nowplaying = fb.GetNowPlaying()
    focused = fb.GetSelection()
    if (fb.IsPlaying && fb.TitleFormat("%artist%").EvalWithMetadb(nowplaying) == fb.TitleFormat("%artist%").EvalWithMetadb(focused)){
        var timer
        timer = window.SetTimeout(function (){
            p.item_focus_change();
        }, 200);
    } else {
        p.item_focus_change();
    }
}

Same for on_item_focus_change
I know, hideous code, there gotta be a more elegant method of comparing the playing and the selected item, but I couldn't figure it out and used something i found somewhere.
But it solved my problem and only adds this tiny delay when its necessary.

What could improve this solution is if I could determine the reason for the selection change- wether it was because I made a new selection or whatever el_playlist does on group selection that causes the selection to jump to now playing.
But I guess thats not possible, or is it?
Doesn't really matter, what I got now is good enough

  • Solynth
  • [*]
WSH Panel Mod script discussion/help
Reply #2505
I wonder if you guys could help me. I'm using Br3tt/Falstaff's WSH Playlist this one here, and I'm trying to get the artist image to display as a wallpaper.
I CAN get it to work when I place the artist.jpg in the album folder. BUT, some artists I have have over 20 albums or so, and rather than having the same artist image in every folder, I would like to just have the artist.jpg saved in the I:\Music\Artist folder. My Library is set up "Music\Artist\Albums".
I am using Biography Server which automatically downloads the artist.jpg from last.fm, the script I am using to save the image to the artist folder is

Code: [Select]
$replace($directory_path(%path%),\%directory%,)\artist


Which is working fine. What I am struggling with however, is getting the WSH Playlist to look here for the artist image.



I've also tried using the same code in Preferences>Display>Artist, but it's not working.
  • Last Edit: 01 August, 2013, 02:41:58 AM by Solynth

  • Falstaff
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2506
CUSTOM Default Wallpaper Path is ... for the default Wallpaper when no "artist" pic is found, so just point the path to a single picture you want to use for this usage.

so, now, to get artist picture from a centralized folder like you want (and like i do), it's quite easy:

1) be sure that all your artists images are saved in this folder and named with the artist name plus the file extension (.jpg i asume)
2) in fb2k Preferences > Display > "artitst" tab, enter the path of this centralized folder with the pattern thaht match the filename of the image of course, in our case, the TAG %artist% give the name of the filname right ?
so enter this: I:\Music\Artist\%artist%.jpg
3) nothing else, the WSH panel properties are already set : CUSTOM Show Wallpaper AND CUSTOM Use Artist Image As Wallpaper are already set to TRUE

HTH

  • Solynth
  • [*]
WSH Panel Mod script discussion/help
Reply #2507
CUSTOM Default Wallpaper Path is ... for the default Wallpaper when no "artist" pic is found, so just point the path to a single picture you want to use for this usage.

so, now, to get artist picture from a centralized folder like you want (and like i do), it's quite easy:

1) be sure that all your artists images are saved in this folder and named with the artist name plus the file extension (.jpg i asume)
2) in fb2k Preferences > Display > "artitst" tab, enter the path of this centralized folder with the pattern thaht match the filename of the image of course, in our case, the TAG %artist% give the name of the filname right ?
so enter this: I:\Music\Artist\%artist%.jpg
3) nothing else, the WSH panel properties are already set : CUSTOM Show Wallpaper AND CUSTOM Use Artist Image As Wallpaper are already set to TRUE

HTH



YES, thank you it's working.

In the Biography Server Last.fm section, I have the cache file path set to:

Code: [Select]
I:\Documents\Foobar\Artist\%artist%


And under Preferences>Display>Artist I have:

Code: [Select]
I:\Documents\Foobar\Artist\%artist%.jpg
I:\Documents\Foobar\Artist\%artist%.png
I:\Documents\Foobar\Artist\%artist%.jpeg


Thanks again, man. Such a good WSH Playlist.

  • Falstaff
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2508
one line is enough
Code: [Select]
I:\Documents\Foobar\Artist\%artist%.*

  • Solynth
  • [*]
WSH Panel Mod script discussion/help
Reply #2509
one line is enough
Code: [Select]
I:\Documents\Foobar\Artist\%artist%.*


Ah, learn something new every day. Cheers.

  • cliffflip
  • [*]
WSH Panel Mod script discussion/help
Reply #2510
Hi marc,
can you show me how to turn the rating panel from horizontal mode to vertical? pretty much like this :



by the way thanks for your help on previous posts, I'm sure I posted thanks but it's deleted somehow.
  • Last Edit: 02 August, 2013, 02:51:20 PM by cliffflip

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2511
it would take very large changes to make that work. i might have a go if i get bored over the weekend.

  • cliffflip
  • [*]
WSH Panel Mod script discussion/help
Reply #2512
it would take very large changes to make that work. i might have a go if i get bored over the weekend.


I have found a way for that, thanks

  • PeteG
  • [*][*]
WSH Panel Mod script discussion/help
Reply #2513
I have found a way for that, thanks

Eh?
Meaning you found a solution and then signed a NDA with yourself?


Edit: Typo
  • Last Edit: 03 August, 2013, 12:12:23 AM by PeteG

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2514
doing it top/down is easy enough. but i was thinking it would look better with 1 star at the bottom and working upwards towards 5. that would have required a bit more effort. which way did you do it?

  • cliffflip
  • [*]
WSH Panel Mod script discussion/help
Reply #2515
I have found a way for that, thanks

Eh?
Meaning you found a solution and then signed a NDA with yourself?


Edit: Typo


sorry I don't understand what you mean   

doing it top/down is easy enough. but i was thinking it would look better with 1 star at the bottom and working upwards towards 5. that would have required a bit more effort. which way did you do it?


from top to bottom, it's more suitable on my skin.
Since I also use the default horizontal layout, I copy the code from common7.js file, paste it to WSH Panel then edit it.

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_path%skins\tests\Scripts\common7.js"
// @name "Rating"
// @author "marc2003"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

function rating(x, y, bs) {
    this.draw = function(gr) {
        if (!p.metadb) return;
        for (i = 1; i < 6; i++) {
            this.img = i > (this.hover ? this.lrating : this.rating) ? this.off_img : this.on_img;
            p.draw_image(gr, this.img, this.x, this.y + this.bs * (i - 1), this.bs, this.bs, "centre");
        }

    }
    
    this.metadb_changed = function() {
        if (!p.metadb) return false;
        this.hover = false;
        this.rating = p.eval("$if2(%rating%,0)");
        this.tiptext = p.eval(this.tiptext_tf);
        this.lrating = this.rating;
        window.RepaintRect(this.x, this.y, this.bs, this.w);
        return true;
    }
        
        this.trace = function(x, y) {
        return x > this.x && x < this.x + this.bs && y < this.y + (this.bs * 5) && y > this.y;
    }
    
    this.move = function(x, y) {
        if (!this.trace(x, y)) {
            if (this.hover) this.leave();
            return false;
        }
        if (p.metadb) {
            if (y > this.y) p.tt(this.tiptext);
            this.hover = true;
            this.lrating = Math.ceil((y - this.y) / this.bs);
            window.RepaintRect(this.x, this.y, this.bs, this.w);
        }
        return true;
    }
    
    this.lbtn_up = function(x, y) {
        if (!this.trace(x, y)) return false;
        if (this.check) {
            if (this.lrating != this.rating && this.hover == 1) fb.RunContextCommandWithMetadb("Rating/" + (this.lrating == 0 ? "<not set>" : this.lrating), p.metadb, 8);
        } else {
            p.MsgBox(this.error_text, 0, p.name);
            p.browser("http://www.foobar2000.org/components/view/foo_playcount");
        }
        return true;
    }
    
    this.leave = function() {
        p.ttd();
        this.hover = false;
        window.RepaintRect(this.x, this.y, this.bs, this.w);
    }
    
    this.x = x;
    this.y = y;
    this.bs = bs;
    this.w = this.bs * 5;
    this.hover = false;
    this.rating = null;
    this.lrating = null;
    this.img = null;
    this.off_img = gdi.Image(p.images_path + "off.png");
    this.on_img = gdi.Image(p.images_path + "on.png");
    this.check = utils.CheckComponent("foo_playcount", true);
    this.error_text = "This script requires foo_playcount.";
    this.tiptext_tf = this.check ? 'Rate "%title%" by "%artist%"' : this.error_text;
}


var p = new panel("Rating", ["custom_background", "metadb"]);
p.version = "7.2013-04-02.01";
p.filename = "rating.txt";
var r = new rating(0, 0, 18);
p.check_version();

on_item_focus_change();

function on_size() {
    p.size();
    r.x = Math.round((p.w - r.w) / 52);
    r.y = Math.round((p.h - r.bs) / 5);
}

function on_paint(gr) {
    p.draw_background(gr);
    r.draw(gr);
}

function on_metadb_changed() {
    r.metadb_changed();
}

function on_mouse_move(x, y) {
    r.move(x, y);
}

function on_mouse_lbtn_up(x, y) {
    r.lbtn_up(x, y);
}


I need a smaller panel, so I resized it too.
  • Last Edit: 03 August, 2013, 03:43:42 AM by cliffflip

  • MordredKLB
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2516
sorry my bad 

here's what I meant anyway : http://tinypic.com/r/2iup7oj/5

I noticed no one responded to your question about this. I can't give you exact code for your theme, but this should give you a place to start.

You'll need to have two copies of the album art. This code assumes you're loading the album art into an image called albumart. I'd suggest, loading it once and then drawing it into the background image like so:
Code: [Select]
    bgImage = gdi.CreateImage(1920,1080);
    background = bgImage.GetGraphics();
    background.DrawImage(albumart, 0, 0, 1920, 1080, 0, 0, albumart.Width, albumart.Height);
    bgImage.ReleaseGraphics(background);
    bgImage.BoxBlur(40, 5);


I went with a medium amount of BoxBlur and then 5 iterations which should give you a nice diffuse background image.

Then just draw bgImage to cover the panel and draw albumart on top of it. I didn't test this code, so apologies if there are any bugs.

  • cliffflip
  • [*]
WSH Panel Mod script discussion/help
Reply #2517
Hi, thanks for your response. I'll test it as soon as I can

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2518
I noticed no one responded to your question about this.


um.... http://www.hydrogenaudio.org/forums/index....st&p=839573

admittedly mine uses a static background wallpaper so if yours generates nice colours on the fly then it is better.

  • mire777
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2519
Here's very simple script for rotating image on playback time.

Code: [Select]
var image = gdi.Image(fb.FoobarPath + "images\\vinyl.jpg");
var angle = 0;

function on_paint(gr) {
  
   gr.DrawImage(image, 0, 0, 500, 500, 0, 0, image.width, image.height, angle);

}
function on_playback_time(time){
  
   if(angle >= 360) angle = 0;
   angle += 60;
   window.Repaint();   
  
}

I tested it with this Vinyl image

ExtremeHunter please can you help me?
I use WSH panel mod 1.4.2. I can't use new version, because it brakes my skin.
This skript work's good, but it is slow. How to set speed in WSH panel mod 1.4.2?

Seems to older version don't recognize ''window.ClearInterval'' , ''window.SetInterval'' and simmilar action's..
  • Last Edit: 08 August, 2013, 10:27:07 AM by mire777

WSH Panel Mod script discussion/help
Reply #2520
I slightly modified the old spinning disc script so that you can use it with 1.4.2 wsh panel mod. pastepin link
  • Last Edit: 08 August, 2013, 12:24:43 PM by ExtremeHunter

  • mire777
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2521
I slightly modified the old spinning disc script so that you can use it with 1.4.2 wsh panel mod. pastepin link


Oh, Thank's Extreme Hunter, you're the best

  • phool
  • [*][*]
WSH Panel Mod script discussion/help
Reply #2522
Hi ExtremeHunter, last time I tried your spinning disk script (for the current version of wsh panel mod, the rotation wan't as smooth as I expected. Is it possible to simulate the effect on this website: http://fanart.tv/artist/477b8c0c-c5fc-4ad2...uuren-van-armin (scroll down to the CDART section)? I'd also like to be able to have the image be linked to actual CDart saved in same folder as the album with the naming scheme: [CD Art] %album artist% - %album%
  • Last Edit: 08 August, 2013, 01:58:55 PM by phool

WSH Panel Mod script discussion/help
Reply #2523
My spinning disc script already does that, you need to set disc image location in foobar Preferences->Display->Disc

"the rotation wasn't as smooth" This component is not meant for such a heavy animation.

  • drm200
  • [*]
WSH Panel Mod script discussion/help
Reply #2524
I have a novice question as I am a novice .. but I've not been able to understand what is causing a panel to react as it does  ..

I have some simple code that I downloaded that displays "now playing" info in a wsh panel.  The panel works fine.  But, when I right click on the mouse .. it shows a menu for properties and configuration and I can click on "configuration" and go into edit regardless of whether I have layout editing mode enabled or not.  All of my other panels do not react to a right mouse click this way.

I want to disable the "configuration" menu unless I have "layout editing" enabled.

The code in this panel has no "right mouse" button functions defined  ..
The code in this panel has no functions working with the popup context menu ...
There are no pre-processors loading other code. ...

Can someone explain why I get this context popup menu on right click with layout edit mode disabled (and not for other panels).... and how I may disable it so one can not go into configuration edit unless layout edit mode is enabled?