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: JScript Panel (Read 285421 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: JScript Panel

Reply #1151
I might investigate and see if it's possible* to download an image and let you use it without the creation of an intermediate file.



*it's obviously possible.... but is it possible for me.  :P

Well, I've got it to work... since it's a radio station I can just overwrite the same file that foobar is using to read tags from. Also, a side note is that I am using m-TAGS and it pairs well with the album art and JS Playlist, only minor issue is I need to keep refreshing JS Playlist to load the new album image, maybe if I implement 'on_playback_dynamic_info_track' into JS Playlist that should work...? unless that refreshes the entire panel and breaks...

Re: JScript Panel

Reply #1152
With the wallpaper option enabled in the JS Playlist settings, you can override the variable manually at any time.

Code: [Select]
images.wallpaper = get_my_image();
window.Repaint();

Playing a new track would always reset it but if you're listening to a stream, this won't be an issue.

Re: JScript Panel

Reply #1153
With the wallpaper option enabled in the JS Playlist settings, you can override the variable manually at any time.

Code: [Select]
images.wallpaper = get_my_image();
window.Repaint();

Playing a new track would always reset it but if you're listening to a stream, this won't be an issue.

Is there an equivalent of panel.item_focus_change(); but for JS Playlist? I can't seem to refresh this unless I hit F5 to refresh the JS Playlist component... Can't seem to get it working with window.Repaint() as well... I've highlighted the part in red which needs to be refreshed after every track change...


Re: JScript Panel

Reply #1155
Is there an equivalent of panel.item_focus_change(); but for JS Playlist? I can't seem to refresh this unless I hit F5 to refresh the JS Playlist component... Can't seem to get it working with window.Repaint() as well... I've highlighted the part in red which needs to be refreshed after every track change...

The group header code is pretty horrible but I have updated it so F5 invalidates the image cache without reloading the whole panel...

https://github.com/jscript-panel/component/commit/357093f1acd0bd6032cc25797a1cba7cf1536bc0

Code: [Select]
p.list.groups.forEach(function (item) {
item.cover_img = null;
});
g_image_cache.reset();
full_repaint();


Re: JScript Panel

Reply #1156
Is there an equivalent of panel.item_focus_change(); but for JS Playlist? I can't seem to refresh this unless I hit F5 to refresh the JS Playlist component... Can't seem to get it working with window.Repaint() as well... I've highlighted the part in red which needs to be refreshed after every track change...

The group header code is pretty horrible but I have updated it so F5 invalidates the image cache without reloading the whole panel...

https://github.com/jscript-panel/component/commit/357093f1acd0bd6032cc25797a1cba7cf1536bc0

Code: [Select]
p.list.groups.forEach(function (item) {
item.cover_img = null;
});
g_image_cache.reset();
full_repaint();



Hey! Thanks for helping me out, just a small doubt that if I want to implement 'on_playback_dynamic_info_track' in JSPlaylist and only affect the image cache after every track change should I use 'g_image_cache.reset();' and 'full_repaint();' within the script panel? inside of on_playback... function?

Secondly, since my Album Art panel does the checking and downloading of album covers is it possible for JSPlaylist to access Album Art panel where I have set my custom variables? it might've been that my code was refreshing before the image has even been downloaded by my Album Art panel?

Re: JScript Panel

Reply #1157
If your artwork panel is handling the updating/fetching of artwork, you can send notifications to other panels with window.NotifyOthers and listen for it with the on_notify_data callback.

https://jscript-panel.github.io/docs/namespaces/window/#windownotifyothersname-info
https://jscript-panel.github.io/docs/callbacks/#on_notify_dataname-info

BTW, I'll have a new release later which allows the download/use of images without saving to file.

Re: JScript Panel

Reply #1158
3.2.20

https://jscript-panel.github.io/docs/

- Add utils.DownloadImageAsync and on_download_image_done Using these in combination allows the download/display of images in memory without the need for saving to file. Use utils.DownloadFileAsync if you want a permanent copy.

Re: JScript Panel

Reply #1159
3.2.20

https://jscript-panel.github.io/docs/

- Add utils.DownloadImageAsync and on_download_image_done Using these in combination allows the download/display of images in memory without the need for saving to a file. Use utils.DownloadFileAsync if you want a permanent copy.


Thanks a lot! It works well with radio stations that don't utilize StreamUrl to serve cover art yet!

Re: JScript Panel

Reply #1160
By the way marc2k3, I've got both my JSPlaylist and Album cover to properly display the custom radio station album covers...

Though I'm not sure if this could be fixed but basically when my album panel downloads the art, it displays first and then sends a notify to my JSPlaylist to update the cover art... Perhaps is there a way to sync the changes so that both the album art and JSPlaylist panels change at the same time instead of one by one?

I've thought of something where first I send the notification to JSPlaylist to refresh and then the playlist component sends a message back to album art panel in which it then changes... Sort of like a 2 way communication... Would this work? or would it produce the reverse effect of what I'm already facing?

Re: JScript Panel

Reply #1161
I'm having trouble getting this component to work in Wine under Linux. All I get is a black panel. The context menu only shows "reload", "properties" and "configure" regardless which script I have set it up with. The sample scripts don't work either. I saw that the newest version requires the latest f2k beta and I have 2.0 (which is all that is currently available from AUR), but v3.0.26 doesn't work either.

Re: JScript Panel

Reply #1162
Azuriye - I have no idea what you're trying to do. Sending confirmation from a panel back to another after a message has been received is possible but why? It's nonsensical.

dpc666 - you won't get this working in WINE. Forget it.

Re: JScript Panel

Reply #1163
Azuriye - I have no idea what you're trying to do. Sending confirmation from a panel back to another after a message has been received is possible but why? It's nonsensical.

dpc666 - you won't get this working in WINE. Forget it.

I wanted to sync JSPlaylist and Album Art panels loading the album image at the same time instead of one by one... As of speaking the Album Art loads the image first and then JSPlaylist.

Re: JScript Panel

Reply #1164
Hi,

I finally found the way to this forum.

I'm trying to migrate the jscript2 2.88 menu button to jscript3 3.2.20 in my skin that is independent of windows scaling since the skin is used on a lot of different windows scalings and the menu button automatically scales under 2.88.

If I use code like this in 3.3.20 which works perfectly in all windows scalings when I set the value of var "scale" to the percentage of windows scaling:

var colours = {
   buttons    : RGB(255, 255, 255),
   normal     : RGB(63,  100, 126),   // JSCRIPT3 Modified
   hover      : RGB(192, 224, 255),   // JSCRIPT3 Modified
   background : RGB(196,  30,  35)
};

var panel   = new _panel();
var buttons   = new _buttons();

// Modified code
var scale   = 250;            // Windows Scaling percentage

var bx   = -5 * scale / 100;
var by   = -7 * scale / 100;
var bw   = 34 * scale / 100;
var bh   = 34 * scale / 100;

var mx   = -4 * scale / 100;
var my   = 25 * scale / 100;

buttons.buttons.menu = new _button(bx, by, bw, bh, { char : chars.menu, colour : colours.normal }, { char : chars.menu, colour : colours.hover }, function () { _menu(mx, my); }, '');

Problem is I just do not know how to set the correct value of "scale" automatically.
In 2.88 I used something like scale = windows.Width / 25 since the width of the calling window was 25px times the windows scaling, but for one reason or another the windows.Width is not set anymore.

How can I set the value of "scale" automatically in 3.2.20?

Re: JScript Panel

Reply #1165
window.Width / window.Height is always zero when fb2k starts so it's why most buttons are created from the on_size function. This is called when window.Width/window.Height get valid values.

A common pattern I use in many of my scripts is having a buttons.update function like this....

https://github.com/jscript-panel/component/blob/66c096863ee57acfc4d24312627cd2e292c5692f/samples/Playback%20Buttons.txt#L41-L52

And then calling buttons.update from on_size...

https://github.com/jscript-panel/component/blob/66c096863ee57acfc4d24312627cd2e292c5692f/samples/Playback%20Buttons.txt#L126

Re: JScript Panel

Reply #1166
Hello marc2k3, is it possible to maybe have some sort of clickable icons where if I click on the heart icon, etc. it writes a value to that file's tag? sort of like the Format Value option.

Or maybe have it interconnected in a way where if I click on an icon it executes a custom script located in Tagging > Scripts > (The script to be executed)?


Re: JScript Panel

Reply #1168
Hi all, hope all is well.
I've just updated to the latest JS Panel release, however I'm getting an error with the Last FM Bio Sample:

JScript Panel 3.2.20 (Last.fm Bio by marc2003)
JavaScript runtime error
Invalid procedure call or argument
File: C:\Program Files (x86)\Foobar2000 2.0 (64 bit)\profile\user-components-x64\foo_jscript_panel3\samples\js\text.js
Line: 119, Col: 5

If I reload it, it works, but every time I re-save my UI, the panel crashes with the above message.

Thanks for any advice you can offer.

Re: JScript Panel

Reply #1169
@hexenszene

foobar2000 v2.0 64bit Standard installation destination.
-C:\Program Files\foobar2000

Configuration folder
-C:\Users\<USERNAME>\AppData\Roaming\foobar2000-v2
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD 490 PRO, DT 1990 PRO, HIFIMAN ANANDA, HIFIMAN Arya, AKG K712 PRO, SONY MDR-1AM2, Bowers & Wilkins P7, FiiO FT5, Bose QuietComfort 45 (made a Upgrade/Balanced Cable by myself) Shall I write more?

Re: JScript Panel

Reply #1170
@hexenszene

foobar2000 v2.0 64bit Standard installation destination.
-C:\Program Files\foobar2000

Configuration folder
-C:\Users\<USERNAME>\AppData\Roaming\foobar2000-v2

Are you asking about my installation?  I actually use a portable installation.

Re: JScript Panel

Reply #1171
@hexenszene , thanks for the report. It's now fixed...

3.0.27 for fb2k 1.6.6 - 1.6.16
3.2.21 for fb2k 2.0 (technically Beta18+ but you should be using final or 2.1 preview by now  :P )

https://jscript-panel.github.io/docs/

Fix issue with `ITextLayout` `CalcTextHeight` where passing an invalid `max_width` would throw a script error.

Re: JScript Panel

Reply #1172
@hexenszene , thanks for the report. It's now fixed...

3.0.27 for fb2k 1.6.6 - 1.6.16
3.2.21 for fb2k 2.0 (technically Beta18+ but you should be using final or 2.1 preview by now  :P )

https://jscript-panel.github.io/docs/

Fix issue with `ITextLayout` `CalcTextHeight` where passing an invalid `max_width` would throw a script error.
You're the absolute best Marc!  🙏