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

Re: JScript Panel

Reply #1575
Hello Mark
I have seen that in the latest update 3.4.22 you have included in the context menu the Library or Playlist option. Fantastic work, thank you very much, I'm sure many fb2 users will love it.


Re: JScript Panel

Reply #1577
Hello, I have asked a question relating to this plugin on the General section and on  Reddit r/Foobar but I have not gotten an answer, If I may ask here:

I am looking for a scripting language to achieve my own simple features in Foobar (either v1 or v2). I know the SDK is available and with it you can pretty much achieve whatever you want but I am not going to be ready to develop with C++ for at least another year. 
 
In the mean time I just need a simple high level scripting interface, to implement some features I want.  Looking around I found   Jscript Panel 3, I have used Jscript in other places before and it seems to at least meet my needs for custom panels in Foobar but I wonder if can be used to as a general scripting language to develop features that do not need any UI/GUI too. 
 
For example, I want to create a feature where if I hold a key down, say f2, the playback will loop between 10 seconds before and after the current playback time. So if I held down f2 when the playback is at 00:00:30, it will continue playing till it reaches 00:00:40, then it will move back to 10 seconds before 00:00:30, to 00:00:20, resume playing till 00:00:40 is reached. It will play in this loop until I release f2
 
When f2 is released the playback will jump to 00:00:30 and play as normal, ie to the end of the song. 
 
Looking at some of the call back functions for Jscript Panel 3, such as   on_key_down(vkey) and   on_key_up(vkey) this seems to be achievable but I reading elsewhere in the documentation, this whole component seems to be only intended for those that want to create their own additional GUIs in Foobar and this would not work as a script that can only be triggered by the keyboard. 
 
I have been using AutoHotkey/PowerShell  but it can be very limited as I don't have direct access to the internal state of Foobar. 
 
Thanks for any help and suggestions you may have

Re: JScript Panel

Reply #1578
The component can do a great many things without a UI. In Columns UI, you can hide panels so that's easy enough. For default UI, you'd need to hide it behind a tab you'd never switch to or modify an existing script that displays something you want while doing whatever you want in the background. For example, I made my own last.fm scrobbler which did background web requests without a UI. It just reported success/failure to the foobar2000 console.

But for what you want, you do need a UI element to actually click on. It's not possible to capture key down/up events without clicking on it. Normal fb2k keyboard shortcuts bound to menu items trigger immediately on key down only with no means for capturing key up. So even if you could write this in pure C++, you'd still need a UI element.

Re: JScript Panel

Reply #1579
Hi Marc a small and sorry if sillyquestion but I am in no way a coder but in most of the sample scripts I have messed around by trial and error and made the changes I needed to font size, colors and such
but in the Basic Sample  @name "Volume + Text" I cant figure out how to change the text size If possible at all please let me know how to do so


Code: [Select]
// ==PREPROCESSOR==
// [member=43500]name[/member] "Volume + Text"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// ==/PREPROCESSOR==

var g_drag = 0;
var ww = 0, wh = 0;

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

function on_paint(gr) {
var volume = fb.Volume;
var pos = ww * vol2pos(volume);
var txt = volume.toFixed(2) + 'dB';
FillGradientRectangle(gr, 0, 0, pos, wh, 0, RGB(27, 27, 27), RGB(255, 128, 0));
FillGradientRectangle(gr, pos, 0, ww - pos, wh, 0, RGB(17, 17, 17), RGB(17, 17, 17));
gr.WriteText(txt, '', RGB(201, 201, 201), -237, 33, ww, wh, 2, 2);
gr.DrawRectangle(0, 0, ww - 1, wh - 1, 1.0, RGB(150, 150, 150));
}

function on_mouse_lbtn_down(x, y) {
g_drag = 1;
}

function on_mouse_lbtn_up(x, y) {
on_mouse_move(x, y);
g_drag = 0;
}

function on_mouse_move(x, y) {
if (g_drag) {
var pos = x < 0 ? 0 : x > ww ? 1 : x / ww;
fb.Volume = pos2vol(pos);
}
}

function on_mouse_wheel(delta) {
if (delta > 0)
fb.VolumeUp();
else
fb.VolumeDown();
}

function on_volume_change(val) {
window.Repaint();
}

PC - Teac UD-505 - Adam Audio A4V - DCA ÆON Open X
Samsung S23 Ultra 512GB - Fiio UTWS5 - TinHifi P1 Max.

Re: JScript Panel

Reply #1580
Add this at the start of the script...

Code: [Select]
// name, pixels, font_weight (400 = normal, 700 = bold)
var font_string = CreateFontString("Segoe UI", 20, 700);

Then modify this line...

Code: [Select]
gr.WriteText(txt, '', RGB(201, 201, 201), -237, 33, ww, wh, 2, 2);

to become...

Code: [Select]
gr.WriteText(txt, font_string, RGB(201, 201, 201), -237, 33, ww, wh, 2, 2);

Re: JScript Panel

Reply #1581
Add this at the start of the script...

Code: [Select]
// name, pixels, font_weight (400 = normal, 700 = bold)
var font_string = CreateFontString("Segoe UI", 20, 700);

Then modify this line...

Code: [Select]
gr.WriteText(txt, '', RGB(201, 201, 201), -237, 33, ww, wh, 2, 2);

to become...

Code: [Select]
gr.WriteText(txt, font_string, RGB(201, 201, 201), -237, 33, ww, wh, 2, 2);
Fantastic thank you dude
PC - Teac UD-505 - Adam Audio A4V - DCA ÆON Open X
Samsung S23 Ultra 512GB - Fiio UTWS5 - TinHifi P1 Max.

Re: JScript Panel

Reply #1582
I'm not familiar with JS, so I have a simple question if someone would be so kind as to answer.

What code do I insert or change to increase the size of the playback buttons?

And one other thing I'd like to do (if possible) is to be able to increase the height of the Spectrogram Seekbar. I can shrink it by dragging border, but its height seems limited to around 5% of total layout height.

Thanks for this wonderful plugin!

Re: JScript Panel

Reply #1583
I'm not familiar with JS, so I have a simple question if someone would be so kind as to answer.

What code do I insert or change to increase the size of the playback buttons?

And one other thing I'd like to do (if possible) is to be able to increase the height of the Spectrogram Seekbar. I can shrink it by dragging border, but its height seems limited to around 5% of total layout height.

Thanks for this wonderful plugin!
I know this one took me a while to figure out a while back but it should be this scale number

it might look weird if the box its in is not the right size so move that around and get it looking as you want

And the RGB codes just above that is where you change the color you can find the RGB codes in Paint color selector or loads of other places
PC - Teac UD-505 - Adam Audio A4V - DCA ÆON Open X
Samsung S23 Ultra 512GB - Fiio UTWS5 - TinHifi P1 Max.

Re: JScript Panel

Reply #1584
I know this one took me a while to figure out a while back but it should be this scale number

Awesome, thank you!
 
I did see how to change colors, but I don't know how I missed something so obvious as "scale = number" :P

I also figured out how to space out and then re-center playback buttons.

Also, I realized it was the minimum required size of tabbed/facets panel that was preventing me from expanding spectrogram seekbar. Adjusting panel beneath that one allowed me stretch spectrogram. So no assistance needed with that one if anyone was wondering.


Re: JScript Panel

Reply #1585

I also figured out how to space out and then re-center playback buttons.

Nice.


How do you change the spacing between the buttons and recenter them? I might want to try that  :))
PC - Teac UD-505 - Adam Audio A4V - DCA ÆON Open X
Samsung S23 Ultra 512GB - Fiio UTWS5 - TinHifi P1 Max.

Re: JScript Panel

Reply #1586
Inside the buttons.update method, each button starts with...

Code: [Select]
this.buttons.BLAH = new _button(...

The first 4 values in the button definition are x, y, w,h

x is the left position, y is the top, w is width and h is... you can guess. :P


Re: JScript Panel

Reply #1587
Advance warning for smooth browser users....

I'm totally nuking the text only column AND the overlay with text options in the next release. The 2 options left intact are those displayed on the docs site as examples right now.

https://jscript-panel.github.io/gallery/smooth-browser/#__tabbed_1_1
https://jscript-panel.github.io/gallery/smooth-browser/#__tabbed_1_2

If you want to keep the options I'm removing, browse the component folder\samples and copy the smooth folder to your profile folder where no component upgrade will ever touch it. Now you'll need to update code in the panel to load these copied files...

Code: [Select]
// ==PREPROCESSOR==
// @name "Smooth Browser"
// @author "Br3tt aka Falstaff"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_profile_path%smooth\common.js"
// @import "%fb2k_profile_path%smooth\inputbox.js"
// @import "%fb2k_profile_path%smooth\scrollbar.js"
// @import "%fb2k_profile_path%smooth\jssb.js"
// ==/PREPROCESSOR==

edit: and here's an attachment for anyone who misses this. Obviously the changelog will mention it but who reads that? :P

Re: JScript Panel

Reply #1588
Inside the buttons.update method, each button starts with...

Code: [Select]
this.buttons.BLAH = new _button(...

The first 4 values in the button definition are x, y, w,h

x is the left position, y is the top, w is width and h is... you can guess. :P


thank you got it to work but it only looks weird with more spacing your standard layout is already so perfect Cheers!  8)
PC - Teac UD-505 - Adam Audio A4V - DCA ÆON Open X
Samsung S23 Ultra 512GB - Fiio UTWS5 - TinHifi P1 Max.


Re: JScript Panel

Reply #1590
Hello Mark
I think the changes for the playList mode are very good, but would it be possible to select several albums at the same time with the Ctrl key? I've tried but I can't get it. It would be very useful to be able to send them to another list, to the Queue, etc.
Thanks for your work.


Re: JScript Panel

Reply #1592
Hi Marck:

I am delighted with the new Smooth Browser that allows Playlist mode. I asked you for this a while ago and you finally decided to implement it.

I also liked that in version 3.4.25 you made it so that in Playlist mode when marking a disc in Smooth Browser it is marked in the active playlist and does not take it to the Library Viewer Selection.

If it is possible, I would like the inverse effect. If we mark a disc in the active playlist it is highlighted in the Smooth Browser.

Re: JScript Panel

Reply #1593
Thanks for the updates, Marc - my foobar is looking ace thanks to your hard work! :-)

One small question - this is my current sort pattern for the Smooth Browser sample:

$if(%date%, %date% | %album% | %album artist% | %discnumber% | %tracknumber% | %title%,zzz%path_sort%)

How can I show the most recent releases at the top (rather than the oldest)?


Re: JScript Panel

Reply #1595
The component can do a great many things without a UI. In Columns UI, you can hide panels so that's easy enough...
I understand much better, I am satisfied with my findings and will proceed with a few example projects in the coming week, thank you for explaining to me all of this, especially the last part.

 

Re: JScript Panel

Reply #1596
Not likely. Multi select in javascript panels is hard and I'm lazy.

Hello Mark
Hopefully in the future it will be possible to select multiple albums. I understand it will take a lot of work to do it, but thanks anyway.

Re: JScript Panel

Reply #1597
3.4.26

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

https://github.com/jscript-panel/release/releases/tag/latest

I totally broke Smooth Browse search in the last release so that been fixed.

There is also partial multi-select support. It works with the Ctrl key only. Using the Shift key for ranges is not supported.

Re: JScript Panel

Reply #1598
Hi! I was using a really old version (3.2.something). I just upgraded to latest and everything's cool, but I wish that the ability to change wallpaper opacity wasn't removed from JSPlaylist. I understand it was "breaking some things", but I had mine set at the highest and I was looking good. Is there a way to access and change the value for JSPlaylist's custom wallpaper opacity? I peeped through the code real quick but I couldn't find the magic number.

I guess alternatively (and the problem here might be Windows 10) I could get the ability to make the background and selection colors of the JSPanel *more* transparent, but I don't know if that makes sense (pertaining to how the backgroung image is displayed through the Panel'l UI). Right now I only get an RGB color picker.

Re: JScript Panel

Reply #1599
The last value (0.1) on this line can be increased...

https://github.com/jscript-panel/component/blob/c51306cd0807db52bbe79133aa22c89b65e570c4/samples/jsplaylist/main.js#L973

edit: the most sensible thing to do is copy the whole function in to the main configuration window.

Code: [Select]
function DrawWallpaper(gr) {
if (images.wallpaper.Width / images.wallpaper.Height < ww / wh) {
var src_x = 0;
var src_w = images.wallpaper.Width;
var src_h = Math.round(wh * images.wallpaper.Width / ww);
var src_y = Math.round((images.wallpaper.Height - src_h) / 2);
} else {
var src_y = 0;
var src_w = Math.round(ww * images.wallpaper.Height / wh);
var src_h = images.wallpaper.Height;
var src_x = Math.round((images.wallpaper.Width - src_w) / 2);
}
gr.DrawImage(images.wallpaper, 0, p.list.y, ww, p.list.h, src_x, src_y, src_w, src_h, 0.1);
}

Copying/modifying it there means it will survive future component upgrades.