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 291995 times) previous topic - next topic
sacduser and 2 Guests 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 #1589
3.4.25

Smooth Browser has been updated as per the advanced warning a few posts up.
Various other Smooth fixes

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

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

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)?