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 83170 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #526
That's why callbacks like on_playback_stop exist.
Yes, but this does not answer my question. or does it?

I believe Marc is saying that in the on_playback_stop you could record a reference to the track.

From what I can tell, I think you're actually confusing having a reference to the last song played with the active playlist item. If I stop a song, and then press play, it isn't that foobar is remembering what the song is, it's just playing from the current position of the active playlist. When I play an entire playlist and then playback stops, when I hit play again, it doesn't play the last song, it plays the first song in the playlist.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #527
If I stop a song, and then press play, it isn't that foobar is remembering what the song is, it's just playing from the current position of the active playlist.

But if I stop a song and then select another item in the active playlist, when I press play the playback does not start from the selected item, but from where the playback stopped. Furthermore, it does so even if I move the selected item above the previously playing song, so that its index is changed, which apparently means foobar is remembering the song and not the position.

I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #528
EDIT: Sorry, I posted in the wrong thread!
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #529
It seems I have no idea what anyone is on about. I thought the original issue was something like this.

Code: [Select]
var g_metadb = fb.GetNowPlaying() // could be a valid handle or null

function on_playback_new_track(metadb) {
    g_metadb = metadb; // always a valid handle
}

function on_mouse_lbtn_up(x, y) {
    if (g_metadb) {
        //code here would run even if playback has stopped so long as g_metadb was valid at some point previously
    }
}

I would "fix" like this...

Code: [Select]
function on_playback_stop(reason) {
   g_metadb = null;
}

g_metadb would always be a valid handle when playing and null when not.

Now it seems the issue has nothing to do with scripts/components at all and is simply not having main menu->"Playback/Playback follows cursor" enabled??

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #530
My issue arises from the need to make a SMP script consistent with that of a PSS panel where titleformatting mode on startup is set to "now playing". Indeed it looks as if PSS is keeping record of the last played track, but I was wondering if this is what's actually going on under the hood or if PSS is referencing some value provided by foobar2000. My question was not how to keep record of the last playing track, which is not a big deal, but whether this supposed foobar2000 internal reference exists and if I'm missing a SMP method the retrieves it.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #531
Hi,

thank you very much for this awesome panel!
I updated almost all of my very outdated WSH panels and Im very happy.

One question - and a request for coding help :/
I am using the sample script of the menu button. I would love to add an onHover image to the menu image though.
Can someone give me pointers into the right direction?

Here is the script I use:
Code: [Select]
'use strict';

window.DefinePanel('Menu Button', {author:'marc2003'});
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
include(fb.ComponentPath + 'samples\\complete\\js\\helpers.js');
include(fb.ComponentPath + 'samples\\complete\\js\\panel.js');

let panel = new _panel(true);
let buttons = new _buttons();
buttons.buttons.menu = new _button(0, 0, 36, 36, {normal : 'misc\\foobar2000.png'}, (x, y, mask) => { _menu(0, 36); }, 'Menu');

function on_focus(is_focused) {
if (is_focused) {
plman.SetActivePlaylistContext();
}
}

function on_colours_changed() {
panel.colours_changed();
window.Repaint();
}

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

function on_mouse_leave() {
buttons.leave();
}

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

function on_mouse_rbtn_up(x, y) {
if (buttons.buttons.menu.trace(x, y)) {
_help(0, 36);
return true;
} else {
return panel.rbtn_up(x, y);
}
}

function on_paint(gr) {
panel.paint(gr);
buttons.paint(gr);
}

function on_size() {
panel.size();
}

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #532
I am using the sample script of the menu button. I would love to add an onHover image to the menu image though.
Can someone give me pointers into the right direction?

From what I gather, you can add the hover image as a property of the fifth argument of the _button() function, which is an object.
If you look at line 10, you will see the img_src argument which is
Code: [Select]
{normal : 'misc\\foobar2000.png'}
Just add another property with key "hover" and value either an image (GdiBitmap), or if you place the image in the  "samples\complete\images" directory, a string with the last part of the image path.
For example
Code: [Select]
{normal : 'misc\\foobar2000.png', hover : 'buttons\\menu_hover.png'}

The _button() function code where you can learn all this is in the "samples\complete\js\helpers.js" script.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #533
Thank you so much, davideleo!

It is hard for me since I am not a programmer at all; I will try out your suggestion today :)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #534
Hi.  I'm I've been racking my brain, trying to create a custom list of my library and I just can't seem to figure it out.  Basically, I want to list all of my artists and then albums.  See table example:

List(Artist, Album, Genre, Total Album Length, Total Number of Tracks, Date, Front, Back, CD)

The fields Front/Back/CD are to test the immediate folder for the contents of Front.jpg, Back. jpg and CD. jpg.

Can this be accomplished using Spider Monkey Panel?  If so, is there sample coding I can work off of?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #535
Hi.  I'm I've been racking my brain, trying to create a custom list of my library and I just can't seem to figure it out.  Basically, I want to list all of my artists and then albums.

I'm very sympathetic to your issue because after some months of studying javascript I was still lost applying it to foobar2000 and the answer marc2003, alias @snotlicker , gave me to a similar question was enlightening and a turning point for me (I still have to thank him for this). You can read the exchange here.

Since that was a jscript panel discussion, here is a spider monkey version of the code, which is also lodash-free.
Code: [Select]
fb.ShowPopupMessage(listByTag("artist").join("\n"));


function listByTag(tag){
    let tags = [];
    let items = fb.GetQueryItems(fb.GetLibraryItems(), tag + " PRESENT");
    for (let i = 0; i < items.Count; i++) {
        let num = fb.TitleFormat("$meta_num(" + tag + ")").EvalWithMetadb(items[i]);
        for (let j = 0; j < num; j++) {
            tags.push(fb.TitleFormat("$meta(" + tag + "," + j + ")").EvalWithMetadb(items[i]));
        }
    }
    return [...new Set(tags)].sort();
}
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #536
I had been using one of the one-panel examples, the text reader script. It crashed my foobar ever so often that I had to take the panel out of my layout.

I didnt add any modifications of the code at all, so I was wondering if there is a known issue with the loading time of this script? I get a "one script on this page is not responding" message when I add it to my layout up to the point foobar2000 will not come up anymore at all.

Its a real shame since I store the contents of audiobooks in a info.txt file.

Any hint very welcome!

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #537
@TheQwertiest

Regarding the callback on_script_unload()

The docs say:

Called when:
- Panel script is reloaded via context menu > Reload.
- Panel script is changed via panel menu > Configure.
- fb2k is exiting normally.
Not called when:
- Script fails with error.
- fb2k closed externally (e.g. killed with process manager).
- fb2k fails with exception.

Do the same restrictions apply as the jscript component that the callback is not guaranteed to be called during unloading.?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #538
@zeremy , AFAIK, JSP has mostly the same behaviour as SMP regarding `on_script_unload`. It's just not listed explicitly.

@Emerelle , does it fail for every track? Or does it fail only on specific file? If the latler, please send me an example, so I can reproduce the problem.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #539
not guaranteed to be called during unloading.?

I think that was inherited from WSH panel mod and I've never given it a moments thought. I guess I should test/update the docs. I'm pretty sure it's always called but the original dev was just being extra cautious.

In addition to the SMP docs you quoted, it should also be called when removing/replacing a panel in layout editing mode.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #540
@TheQwertiest It fails on load, when I start foobar. I get a notification that a script takes too long to load and if I want to stop it or wait for it to load. Sometimes even foobar does not load at all anymore and I have to kill the process.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #541
Recently (after updating the player), the script started to crash, this is observed on some audio.

I understand that the code was developed in collaboration with marc2k3, can here take the files
https://github.com/marc2k3/foo_jscript_panel
only problem is that samples are there in TXT no JS

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #542
Hey, I downloaded the SMP debug and now I'm getting this error whenever I try to open Foobar. What can I do to fix this? I'm also somewhat new to foobar so I apologize if this is a stupid question lol:

Error: Spider Monkey Panel v1.3.2-beta+f0830b60 ({269F9404-C9AD-4BFA-957D-26628B44C199})
include failed:
ActiveXObject_Constructor failed:
Invalid CLSID: UIHacks

File: JStheme_common.js
Line: 863, Column: 26

Stack trace:
  oUIHacks@JStheme_common.js:863:26
  @JStheme_common.js:1023:17
  @<main>:1:1

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #543
not guaranteed to be called during unloading.?

I think that was inherited from WSH panel mod and I've never given it a moments thought. I guess I should test/update the docs. I'm pretty sure it's always called but the original dev was just being extra cautious.

In addition to the SMP docs you quoted, it should also be called when removing/replacing a panel in layout editing mode.


@snotlicker
I found that the culprit not letting me run the callback in a script was your helpers.js that was an include.
It has the function
Code: [Select]
function on_script_unload() {
_tt('');
}
in it 
and the second on_script_unload() in my script didn't get executed.

Maybe some sanity checks are needed as to define the same function only once.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #544
The normal convention in javascript is that if a function with the same name is defined more than once, the last version always takes precedence. For example...

Code: [Select]
function message(name) {
    console.log("hello", name);
}

function message(name) {
    console.log("bye", name);
}

message("zeremy"); // always outputs "bye zeremy"

But the include function built in to SMP breaks this convention so if the first definition is inside an include file, that will take precedence instead.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #545
Quick hack, complete\js\thumbs.js, line 492
^Forget I posted that. It will lead to undesirable/buggy behaviour. It could be done properly but I'm far too lazy for that.
Thanks for trying though  :)
I hope it can be done properly by TheQwertiest or you at some point, because low-res art tends to ruin the whole Thumbs experience.

In my case I have a nice bio on the left half of the screen... and quite often I have a low-res art on the right half, even though I know that many hi-res pics exist for the same artist/album.
Hi-res art should definitely be prioritized IMHO (when available). It's not about completely avoiding low-res, but rather about preferring hi-res when possible. Fingers crossed.  :)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #546
This might work instead...

Code: [Select]
	this.update = () => {
this.image = 0;
this.files = [];
this.images = [];
_(_getFiles(this.folder, this.exts, false))
.map((item) => {
var img = gdi.Image(item);
return {
path : item,
image : img,
area : img.Width * img.Height
};
})
.orderBy((item) => {
return item.area;
}, 'desc')
.forEach((item) => {
this.files.push(item.path);
this.images.push(item.image);
});
this.size(true);
window.Repaint();
}

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #547
This might work instead...
Thanks, trying to make it work :)

EDIT - doesn't seem to work.
I have tried it on Beyoncé. It seemed like a good example, since her last.fm page has 5000+ pictures, some low-res, some hi-res.
The modified Thumbs.js just appears to download the first n pictures in her page (in my case the first 10 pictures), regardless of their size.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #548
That code is simply for re-arranging files that are inside the folder. Don't like it? Don't use it.

Do I really need to tell you that asking about thousands of images online is ****ing insane.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #549
I may have missed something, but I don't think I was rude at all in my message. So why are you ?  :o

Do I need to remind you what was kindly requested months ago in the first place ?
@wcs13 , it might be possible to implement such logic in the script (ignoring low-res images that is), but I'm currently prioritizing component development over script improvement. In other words it won't be fixed anytime soon, sorry.

You just posted a bit of code, with no indications of what it's supposed to do.
I'm not a dev. So of course I didn't examine the code, because I thought you were answering to what was requested.
Now you say that your code was only for re-arranging images (from hi-res to low-res in foobar I guess), which has little to do with what was requested (ignoring, not re-arranging).

Now don't get me wrong : I'm grateful for your bit of code and I'm grateful for you wanting to help.
It's of course better than nothing, but it's hardly a solution, because if Thumbs.js downloaded a majority of low-res images in the first place, then sorting them will not be very useful, unless we're only interested in the first or second image.

BTW, did I ever ask about parsing thousands of images online ? No !  :o  I'm not that stupid.
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.
  • In some cases, if after parsing all the images (some artists have very few images) we don't have n saved images, then save some low-res images too until we have n saved images.
If we are reasonable with the enough-res resolution (e.g. 360.000 pixels min, that's 600x600), we won't need to ignore lots of images. So for n saved images, I guess we may need to parse 1.5n images, maybe 2n images, but hardly more.

I guess that's what @TheQwertiest suggested that he'd do when he'd have some time. If somebody is willing to do it, I'm sure I won't be the only one to be grateful. If not, then I'll just keep waiting. There's nothing else I can do.

BTW here's how my 32" 1440p display looks with a low-res image (see attached file). Like I said, it ruins the whole experience a bit.

 
SimplePortal 1.0.0 RC1 © 2008-2020