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: Spider Monkey Panel (foo_spider_monkey_panel) (Read 342265 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #475
@MordredKLB , try smth like this:
Code: [Select]
{
    "compilerOptions": {
        // this is needed to suppress built-in browser objects (`window`, various DOM objects and etc)
        "lib": ["es2019"]
     },
    "include": [
        // project files
        "**/*.js",
        // docs
        "../../user-components/foo_spider_monkey_panel/docs/js/*.js"
    ],
}

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #476
@MordredKLB , try smth like this:
Code: [Select]
{
    "compilerOptions": {
        // this is needed to suppress built-in browser objects (`window`, various DOM objects and etc)
        "lib": ["es2019"]
     },
    "include": [
        // project files
        "**/*.js",
        // docs
        "../../user-components/foo_spider_monkey_panel/docs/js/*.js"
    ],
}
Yup, that's what worked for me. BTW, I've made a ton of changes to the JSDoc stuff to fix VSCode false positives. Should I submit a PR for that? Not sure if everything currently works okay in intelliJ.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #477
Yup, that's what worked for me. BTW, I've made a ton of changes to the JSDoc stuff to fix VSCode false positives. Should I submit a PR for that? Not sure if everything currently works okay in intelliJ.
Sure, I will take a look.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #478
I discovered this evening that gdi.LoadImageAsync can return the same task ID at certain times which was a serious problem

I've tried to load 1000 images multiple times and didn't manage to reproduce the problem. Are you sure that the task id collision happened before it was utilized in `on_load_image_done()`? I.e. reuse of task id can only happen after the task_id is consumed by `on_load_image_done()` (which makes said task_id unused and available for further usage).

[edit]: Nvm, reproduced and fixed.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #480
Thanks to your screenshot, just spotted a bug in the Properties script where subsong index is undefined. This is because of case sensitivity again...

https://github.com/TheQwertiest/smp_2003/blob/7fc1d75cd73081e3a83cb16e6af0ef2405342150/js/list.js#L983

panel.metadb.Subsong should be panel.metadb.SubSong

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #481
Thanks to your screenshot, just spotted a bug in the Properties script where subsong index is undefined.
Haha, nice catch =)

Btw, could you help with the `Last.fm Loved Tracks Manager` script screenshot (I can crop it myself if needed) and/or description, please? I've never used Last.Fm for anything other than scrobbling...

PS: It also appears that `track info + seekbar + buttons` script is borked, both on SMP and JSP. Hopefully, I have enough JS knowledge left to fix it :D

 

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #482
How is the track info+seekbar+buttons borked? I'm sure you know about the font requirements for the buttons. Perhaps your panel is far too big? Ideal height is around 60-80px

The behaviour of the seekbar where if you move your mouse too far away while dragging and the grip is released... that's by design.



edit: the last.fm lover script has this description inside it...

Code: [Select]
/*
This script makes use of the Spider Monkey "Playback Stats" database to import
and store loved tracks from Last.fm. Each loved track will have the value of
%smp_loved% set to 1. You can access this through all other components/search -
it works in the same way as "foo_playcount" - all values are stored in a database
file and no files are tagged. Each record is bound to "%artist% - %title%" so
common tracks across different albums will share the same loved status. Right click
the heart iocn to set your Last.fm username and authorise the script through your
browser. You can then import all your loved tracks and then use the heart icon
to love/unlove tracks.
*/

edit2: Of course the glaring error in that text is that you won't see a heart icon until AFTER you've configured your username and authorised through your browser. Until, then you'll see a little red exclamation mark.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #483
Btw, could you help with the `Last.fm Loved Tracks Manager` script screenshot (I can crop it myself if needed) and/or description, please? I've never used Last.Fm for anything other than scrobbling...


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #484
Perhaps your panel is far too big? Ideal height is around 60-80px
Yep, that was it =)

edit: the last.fm lover script has this description inside it...
Thanks!

@VlaKor , thank you as well =)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #485
Speaking of Last.fm Loved Tracks Manager, is there a way to indicate in playlist with a value which tracks are loved? The only way to see is to go to the lastfm website or when a track is playing.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #486
@jazzthieve , if your playlist supports the display of custom tags, you can use `%smp_loved%` to get the value for the track (1 - loved, 0 - not really...).

E.g. `$ifequal(%smp_loved%,1,♥,)`.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #487
Great, thanks.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #488
Version: 1.3.1
Link: https://github.com/TheQwertiest/foo_spider_monkey_panel/releases/tag/v1.3.1
Changelog
Hotfix for v1.3.0 (see changelog above)
Spoiler (click to show/hide)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #489
Haven't noticed any issues with 1.3.1. Thanks for being so responsive.

In my playlist, I've got hyperlinks that will create/replace the current playlist with a new search based on what you clicked on. I.e. you click on the artists name and the playlist just shows all songs by that artist. It bugged me that if I was playing a song by Tool for instance, and clicked on the artist name, calling plman.ClearPlaylist(pl) would also lose the playing status of the current playing song (i.e. it wouldn't show as being played anymore even though it's metadb was in the contents of the playlist).

So I devised this workaround to remove everything from the playlist except what was being played, then add the contents of the search back in:

Code: [Select]
const pl = plman.FindOrCreatePlaylist('Search', true);
if (pl === plman.PlayingPlaylist && plman.GetPlayingItemLocation().PlaylistIndex === pl) {
plman.ClearPlaylistSelection(pl);
plman.SetPlaylistSelection(pl, [plman.GetPlayingItemLocation().PlaylistItemIndex], true);
plman.RemovePlaylistSelection(pl, true);

const playing = new FbMetadbHandleList(fb.GetNowPlaying());
handle_list.Sort();
const handle_copy = new FbMetadbHandleList(handle_list);
handle_copy.MakeIntersection(playing);
if (handle_copy.Count === 0) {
plman.ClearPlaylist(pl);
} else {
handle_list.MakeDifference(playing);
}
plman.InsertPlaylistItems(pl, 0, handle_list);
} else {
// nothing playing or Search playlist is not active
plman.ClearPlaylist(pl);
plman.InsertPlaylistItems(pl, 0, handle_list);
}

This works, but it seems incredibly hacky to me, and is hard to read. Is there a better/another way to remove items from a playlist than using RemovePlaylistSelection, or otherwise do this?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #490
Not sure modifying the contents of any existing playlist is the way to go if other people are using this?? To be safe, I'd be sending the contents of the query to a new playlist every time.

But if you really want to remove the playing track from the handle list of results, use BSearch to find its index and remove it.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #491
@MordredKLB , it's just the way fb2k works - played item is bound to the playlist it's playing on. If you clear a playlist then it's no longer bound to it (from fb2k point of view). So, yeah. The only way you can preserve this connection is by removing all other items like you currently do (but you can simplify it a bit via BSearch as suggested by @snotlicker ).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #492
Not sure modifying the contents of any existing playlist is the way to go if other people are using this?? To be safe, I'd be sending the contents of the query to a new playlist every time.

But if you really want to remove the playing track from the handle list of results, use BSearch to find its index and remove it.
It uses a specific playlist each time. Think of it like the CUI "Filter" playlist, or WillB's "Library Playlist". When you make a new selection the contents of that specific playlist are always replaced.

I want to do the opposite of removing the playing song. :) I want to see if the currently playing song is in the results of the search, and if so, remove everything else and then add the results of the search.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #493
@MordredKLB , it's just the way fb2k works - played item is bound to the playlist it's playing on. If you clear a playlist then it's no longer bound to it (from fb2k point of view). So, yeah. The only way you can preserve this connection is by removing all other items like you currently do (but you can simplify it a bit via BSearch as suggested by @snotlicker ).
I'm not sure how BSearch helps since I've already got the index from plman.GetPlayingItemLocation().PlaylistItemIndex.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #494
I was talking about this....

Code: [Select]
	const playing = new FbMetadbHandleList(fb.GetNowPlaying());
handle_list.Sort();
const handle_copy = new FbMetadbHandleList(handle_list);
handle_copy.MakeIntersection(playing);
if (handle_copy.Count === 0) {
plman.ClearPlaylist(pl);
} else {
handle_list.MakeDifference(playing);
}

...but maybe I have no idea what you're doing at all. If whatever it's supposed to do works, just leave it and forget I said anything. :D

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #495
I was talking about this....

...but maybe I have no idea what you're doing at all. If whatever it's supposed to do works, just leave it and forget I said anything. :D
I gotcha. Sorry I misread what you were saying earlier. This is much cleaner now:

Code: [Select]
handle_list.Sort();
const index = handle_list.BSearch(fb.GetNowPlaying());
if (pl === plman.PlayingPlaylist && plman.GetPlayingItemLocation().PlaylistIndex === pl && index !== -1) {
// remove everything in playlist except currently playing song
plman.ClearPlaylistSelection(pl);
plman.SetPlaylistSelection(pl, [plman.GetPlayingItemLocation().PlaylistItemIndex], true);
plman.RemovePlaylistSelection(pl, true);
plman.ClearPlaylistSelection(pl);

handle_list.RemoveById(index);
} else {
// nothing playing or Search playlist is not active
plman.ClearPlaylist(pl);
}
plman.InsertPlaylistItems(pl, 0, handle_list);
Thanks!

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #496
So I've noticed something kind of annoying with Georgia in FSM. When I start up foobar, everything has to spin up as my library loads and FB checks for changes. At the same time FSM is trying to parse my theme, and it's not uncommon to get a "this script is taking too long would you like to kill it" message. It appears that when the dialog is up, FSM freezes the scripts so even though they'd become responsive by the time you have a chance to click continue/kill it doesn't happen. Is there some way to increase the timeout before this warning when foobar is starting up... or not pause the scripts and clear the dialog if they do become responsive again?

Alternatively, is there something I can do in my scripts at startup to prevent this from happening?

BTW, don't know if it matters but my configuration is just a single include of a georgia-theme.js file, and that georgia-theme.js file is what actually includes all the js files for the theme. Figured that would give me more flexibility when updating the theme to add/remove files at will, but maybe the nested includes cause issues?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #497
Is there some way to increase the timeout before this warning when foobar is starting up...
Nope, won't be changed.

Quote
or not pause the scripts and clear the dialog if they do become responsive again?
That would be neat. I'll see if it's possible to do this.

Alternatively, is there something I can do in my scripts at startup to prevent this from happening?

The proper way to avoid holding stuff for long time would be to make initialization segmented, which would yield the control after each segment is completed (with smth like a progress bar). E.g.
Code: [Select]
// This is pseudo-code

is_initializing = true;

function on_paint() {
  if (is_initializing) {
    print_loading_in_progress();
  }
  else {
    print_normal_stuff();
  }
}

function init_short()
{
  // basic init that doesn't hold for long
}

async function init_long() {
  while (has_stuff_to_do) {
     let promise = new Promise((resolve) => {
       stuff_to_do = get_current_init_part();
       stuff_to_do.do();
       resolve(stuff_to_do.id)
     });
     stuff_id = await promise; // this will yield the execution
     console.log(`$(stuff_id) done`);
  }
  is_initializing = false;
}

init_short();
init_long();

Figured that would give me more flexibility when updating the theme to add/remove files at will, but maybe the nested includes cause issues?
The panel is considered a single script. I.e. it doesn't matter if it uses `include()` or just has everything inlined.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #498
I might try some tests with async/await wrapping includes. The warning seems to be entirely dependent on whether my hard drives need to spin up first... something I haven't been able to get to happen today. If the HDD is spinning, FSM loads my theme in <300ms at startup. Refreshing the panel after foobar has started takes about 20ms, so it's not that the script is actually slow.

BTW, I stupidly had clicked the "don't show me this again" checkbox. Is deleting the foo_spider_monkey.dll.cfg good enough to reset that? It didn't reset the panel configuration so some data is being stored elsewhere at least.

Edit: Rebooted my computer and got this to happen again. Async processing of files won't help the situation. I verified the file it had hung on last time, and it's the very second file I include, and it died at line 70, where I define the RGB helper function. Not exactly a tight loop.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #499
Using;
handle_list.AttachImage(img_path, 0)
If img_path contains ( or ) then image file is not found.