Skip to main content

Notice

If you are using a Hotmail or Outlook email address, please change it now, as Microsoft is rejecting all email from our service outright.
Topic: Spider Monkey Panel (foo_spider_monkey_panel) (Read 93449 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #550
Is it possible to rename the main menu entries? (I was expecting it would be available on the preferences panel)
XX

Why? Because adding those menu commands to standard foobar buttons give the menu name as tool-tip texts.
X

Renaming the menu entries would give a clue of what they do without having to use text buttons.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #551
I've been trying to find a convenient way to view, select and automatically cycle through all the images which are in the same folder as a song, and also a subdirectory below. The "Artist Images"/"thumbs.js" script which is included is nearly perfect.

But currently, it only shows images from the same directory as the music file - using this:
Code: [Select]
$directory_path(%path%)
How do I set it up so that it also shows images from a directory below the file (for example, if there's a folder filled with covers)?
In addition, is it possible to also have it show embedded album art? Currently it can't.

So in summary, I'd like it to show the images in the same folder, the images in any folder which is directly below, and embedded images.

The last and smallest thing that would be nice to have, is to somehow change this background color (currently black):


The included setting doesn't change it.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #552
Probably not exactly what you needed, since I'm using other script. But sure you can take the path part to suit your needs.

Code: [Select]
window.DefinePanel("LoadImageAsync", { author: "XXX" });

let sel = ""
let path = ""

if (fb.IsPlaying) {
    sel = fb.GetNowPlaying();
    path = fb.TitleFormat("$directory_path(%path%)").EvalWithMetadb(sel);
}

// Get a list of jpg files from a folder
var pathart = ""

if (utils.FileTest(path + '\\art', "e"))
    pathart = '\\art\\';
else if (utils.FileTest(path + '\\artwork', "e"))
    pathart = '\\artwork\\';
else if (utils.FileTest(path + '\\_artwork', "e"))
    pathart = '\\_artwork\\';

const g_image_list = utils.Glob(path + pathart + '*.jpg');
let ww = 0, wh = 0;
let g_img = null;
let g_valid_tid = 0;

// Trigger every 5 seconds.
let g_timer = setInterval(function () {
    load_random_image_async();
}, 5000);

load_random_image_async();

function on_playback_new_track() {
    let g_timer = setTimeout(function () {
        window.Reload();
    }, 1000);
}

function on_playback_starting() {
    let g_timer = setTimeout(function () {
        window.Reload();
    }, 1000);
}

function load_random_image_async() {
    // Load a random image from the list
    let path = g_image_list[Math.floor(Math.random() * g_image_list.length)];
    // on_load_image_done will be triggered when the image has been loaded
    g_valid_tid = gdi.LoadImageAsync(window.ID, path);
}

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

function on_paint(gr) {
    if (!g_img) {
        return;
    }

    let scale_w = ww / g_img.Width;
    let scale_h = wh / g_img.Height;
    let scale = Math.min(scale_w, scale_h);
    let pos_x = 0, pos_y = 0;
    if (scale_w < scale_h) {
        pos_y = (wh - g_img.Height * scale) / 2;
    }
    else if (scale_w > scale_h) {
        pos_x = (ww - g_img.Width * scale) / 2;
    }
    gr.DrawImage(g_img, pos_x, pos_y, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);
}

// After loading image is done in the background, this callback will be invoked
function on_load_image_done(tid, image, image_path) {
    if (g_valid_tid === tid) {
        g_img = image;
        window.Repaint();
    }
}

"Pathart" is the subfolder part you want. Ex:
ACDC/Black in black/Artwork/front.jpg
ACDC/Black in black/Artwork/...
ACDC/Black in black/track1
....
ACDC/Black in black/cover.jpg

I only have 3 possible artwork sub-folder names, so that's the 3 "if sentences" part.

Then const g_image_list = utils.Glob(path + pathart + '*.jpg') just merges the file path (track folder) with the subfolder path and takes all jpg files. It should work with any other extension, but beware I have no idea if js displays png or other image files right. I just note you can put whatever you want on that list.

So the first part of this script should work for you in your script in some way. It just displays 1 image at a time and cycle it.

About adding the embedded artwork, I have a "cover.jpg" file present on the base folder, so that's what I would check. Adding that file to the image list too. If you talk about the cover within the track, then you can check "GetAlbumArtAsync.js" on samples folder.


EDIT: After re-reading.. btw if it's just a matter of config editing and you can put whatever tittle-formatting you want then:

$directory_path(%path%) --> $directory_path(%path%)\artwork

That should do. Or your desired subfolder name. (Note, anyway, that would restrict the images to just the subfolder).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #553
EDIT: After re-reading.. btw if it's just a matter of config editing and you can put whatever tittle-formatting you want then:

$directory_path(%path%) --> $directory_path(%path%)\artwork

That should do. Or your desired subfolder name. (Note, anyway, that would restrict the images to just the subfolder).

Thanks. However, I can't find any "GetAlbumArtAsync.js" file anywhere, and probably wouldn't know what to do with it.

The way I can select particular images with the "thumbs.js" script is quite slick and practical, and something similar would be a must if I'm going to bother with this. But it seems it may not be possible to simultaneously view images from folders, subfolders and embedded images while using it.

I also don't mind using other scripts if there's ones which would work for all this. It's just that without being able to view all three sources simultaneously (images in folders, subfolders, and embedded), most of the album art in my different collections would end up missing.

There's an older WSH artwork script which might work and I want to try, hopefully someone can reupload it:
https://hydrogenaud.io/index.php?topic=77883.msg991453#msg991453

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #554
Hi.  I have a strange issue using the on_mouse_mbtn_up function.  When my script is in an embedded panel, I have to double click to get the desired result.  A single click is ignored.  But when the same script is in a foo_flowin pop-up panel, it works just fine.   I also use on_mouse_lbtn_up and it works fine either way.  Does any one have an idea what might be causing this? 

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #555
Ignoring low-res images can be much simpler. I assume you know lots of ways to do it. Here's one :

    Check image 1. If enough-res, save it, or else ignore it. Go to the next image.
    Repeat until you have n enough-res saved images.
That's actually the problem. To get image dimensions you need to download it. So, if there are only low-res images, you'll have to download all those images first.

Is it possible to rename the main menu entries? (I was expecting it would be available on the preferences panel)
I have plans to totally rework `main menu buttons` feature (and make it possible to generate buttons dynamically), but I don't think it will be done any time soon.

Hi.  I have a strange issue using the on_mouse_mbtn_up function.
What do you mean by "embedded panel"? Also can you attach an example script that has such problem?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #556
Thank you for responding.  I used the term "embedded panel" to refer to a normal Foobar panel as defined with splitters, as opposed to pop-up panels created with foo_flowin.  And I found the problem.  Another component was set up to use the middle mouse button, even though I had never used it.  I redefined the keys used by that component and on_mouse_mbtn_up now works as expected with a single click.  I've just started learning Spider Monkey scripting and am amazed at the power and flexibility it offers.  Thank you very much for this amazing component and the excellent documentation you provide.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #557
Quote from: TheQwertiest
Is it possible to rename the main menu entries? (I was expecting it would be available on the preferences panel)
I have plans to totally rework `main menu buttons` feature (and make it possible to generate buttons dynamically), but I don't think it will be done any time soon.

That would be much appreciated.

Also, would it be possible to add a Find(handle) → {number} function with configurable order (inverted too)? Or one which outputs all coincidences?

I'm working on a remove duplicates" function (more advanced than 'same raw path'), while maintaining playlist order by duplicating handles and working on sorted lists on parallel to the original one (A).
For 17K tracks that means 1.5 seconds (A). 327 seconds working without cloned sorted list. And 369 ms if I don't care about original order at all.

The problem I got for (A) is that remove(handle) removes all coincidences (but I one to maintain one!), so I use Find(handle) to  then remove by ID at the original unsorted list. But... it obviously outputs just one match, instead of all. And it always search from the start of the list, so the removed position is not configurable.

I'm currently doing this within some loops and other code (for tags):
Code: [Select]
									let handleAidx =[];
let idx = handle_list.Find(handleA); //Needed. Or it would remove all instances of the same handle!
let idxcache = idx;
while (idxcache != -1) {
handle_list.RemoveById(idxcache);
idxcache = handle_list.Find(handleA);
}
handle_list.Insert(idx,handleA); //It was last copy. Revert once to first place.
break;
With oriented search it would convert to:
Code: [Select]
									let idxA = handle_list.Find(handleA); 
let idxB = handle_list.Find(handleA,-1); //Inverse
while (idxA != idxB) {
handle_list.RemoveById(idxB);
idxB = handle_list.Find(handleA,-1);
}
break;

Or find array result:
Code: [Select]
									let findArray= handle_list.Find(handleA);
let i = findArray.length;
while (i--) {
handle_list.RemoveById(findArray[i]);
}
break;
Which would be so much better and faster.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #558
Hi, I am using the Spider Monkey panel and the included sample file "js smooth browser" for a cover art browser.
My question is, is there a way to actually cache the artwork to local disk? My music is stored on a NAS and the artwork is embedded in the flac files.

There is a setting that can be selected in the popup menu "Enable Disk Image Cache" but this seems broken/has no effect. Everytime foobar is restarted, the panel has to reread the art from remote files.

Thanks.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #559
Utils.Version returns the version of SMP, but I was wondering if there a way to get the version of foobar currently running?

 


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #562
How do I load a playlist by path?
LoadPlaylist() doesn't accept any argument according to the documentation

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #563
plman.AddLocations. It expects an existing playlistIndex as one of the args so you might want to create a new one with plman.CreatePlaylist first.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #564
plman.AddLocations. It expects an existing playlistIndex as one of the args so you might want to create a new one with plman.CreatePlaylist first.
Yep, got it working. The idea is to have a playlist manager with {names/paths} and load playlists on foobar only on demand (instead of cluttering the playlist tab with all playlist loaded at the same time). So the name (and thus new ID needed) will be already given by the object. Thanks!



Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #567
@TheQwertiest FYI, the latest nightly causes foobar to crash on startup.
Are you using DUI? (https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/129)
Yup. I'll give the new nightly a look.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #568
Using nightly build (v1.3.2-beta+9a1b2b36).

Exploring the changed features. panel properties/ configuration (one with three tabs). Can you please make this re-sizeable. Also on the properties tab (same as old version), can you please increase the width of the horizontal splitter as it's very difficult to grab with the mouse and move.

On a more general note, I hope all your great ideas for v2 have been included into the single project git project.

Looking forward to the next official version.

Thanks for your efforts. They are very much appreciated.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #569
Can you please make this re-sizeable.
I'd like to, but, TBH, my UI programming skills are close to non-existent >_<
But I will try...

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #570
Speaking about the properties panel (I'm using the stable release btw), could the keys be sorted following natural number order?

X
As is, it's currently broken for anything over 9. 10 appears after 1. Or should I force it adding zeros? (most times I don't know how many properties will be created with my buttons framework so it's not trivial)

Btw, are you open to any other suggestion for the panel?
- I'm thinking about predefined values: if you set true to a property, the panel already shows a dropdown with true/false. Allowed values could be set with the current set function as a third argument (not breaking current scripts).
-Could a property panel be created according to an ID? Right now I just add properties sequentially to the current SMP panel whenever I merge/add buttons... I assign different IDs and prefixes to the properties so every button has it's own set. But obviously that add a ton of variables to the properties panel. Creating panels on demand with an ID would solve that, I would simply assign every panel to its own button. Then overriding the menu on right click to show button properties instead of panel properties.
X
As you see, I'm currently doing it with prefixes + numbers at script loading, so at least the sorting part would be a lifesaver.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #571
Speaking about the properties panel (I'm using the stable release btw), could the keys be sorted following natural number order?
Not sure, I need to check if there's any built-in sorting function that allows to do that, since I don't want to drag a big chunk of code in component just for that.

For now you can just append three zeroes, I mean I doubt that there'll be more than 1k buttons :D

- I'm thinking about predefined values: if you set true to a property, the panel already shows a dropdown with true/false. Allowed values could be set with the current set function as a third argument (not breaking current scripts).

I was entertaining this idea, actually. This is one of the big features that I want to work on:
- additional display mode for Properties dialog: properties are displayed as a tree view, where `.` character is used as a separator.
- support for arrays (yet to figure how it will work though).
- ability to set property type explicitly (in dialog and via JS).
- support for enum values (the feature that you are requesting).
- ability to manipulate properties as a json (where objects are generated the same way as the tree view).

Not sure when I'll come around to implementing all that though.

-Could a property panel be created according to an ID? Right now I just add properties sequentially to the current SMP panel whenever I merge/add buttons... I assign different IDs and prefixes to the properties so every button has it's own set. But obviously that add a ton of variables to the properties panel. Creating panels on demand with an ID would solve that, I would simply assign every panel to its own button. Then overriding the menu on right click to show button properties instead of panel properties.
As you see, I'm currently doing it with prefixes + numbers at script loading, so at least the sorting part would be a lifesaver.
The `panels` you are talking about are virtual panels, but there is no such concept in SMP right now and I don't think I want to introduce it and there several reasons for that:
- This is quite a big feature. The proper concept introduction will require quite a lot of new API (and component code to support it).
- It's use-case is quite niche. In 99,999% cases buttons don't need any additional properties and usually work just as a dumb callback-invoker.

So, while idea itself is pretty cool, I just don't have any spare capacity to work on it (being the sole maintainer of this project and all that)...

However, I do think you'll be able to work around your problems with the Properties rework, that I've mention above (without having to resort to implementing `virtual panel`s in SMP).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #572
I just don't have any spare capacity to work on it

To give you some idea on the workload: just a small overview of all the currently planned features for next releases: https://github.com/TheQwertiest/foo_spider_monkey_panel/projects/1#column-3416309

And that's not counting all other projects that I want to work on... >_<

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #573
And that's not counting all other projects that I want to work on... >_<
The pain is real. It's why I seem to never succeed in finishing anything :D

Thanks for all the amazing work on SMP though!

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #574
@Qwertiest
Not wishing to add to your workload too much... any chance of changing the file name sent to an external editor. At the moment it is smpxxxx.tmp. To help get the most out of MS Code for example, it would be good if the file name used was smpxxxx.js.

ps Thanks for the easier-to-grip properties splitter

 
SimplePortal 1.0.0 RC1 © 2008-2021