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 script discussion/help (Read 317782 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #1475
@marc2k3 I have a small doubt regarding context commands, is it possible to run context commands on another panel which isn't a JScript panel?

Re: JScript Panel script discussion/help

Reply #1476
Probably should be a large doubt. These are context commands provided by the fb2k SDK which you also see by right clicking a playlist/library item/selection.



I cannot run menu commands from other panels. :/

Re: JScript Panel script discussion/help

Reply #1477
I cannot run menu commands from other panels. :/

Oh thanks for clarifying, I've posted a request to a dev if he could expose it as a main menu command instead.

Re: JScript Panel script discussion/help

Reply #1478
Bit of a hacky workaround but since that component is playlist based, how about forcing a refresh? To be useful, it must already respond to playlist callbacks such as items being added/removed so do that with a bit of JS. I assume it would read new art if this happens?

Re: JScript Panel script discussion/help

Reply #1479
Bit of a hacky workaround but since that component is playlist based, how about forcing a refresh? To be useful, it must already respond to playlist callbacks such as items being added/removed so do that with a bit of JS. I assume it would read new art if this happens?

I'm not sure which component your talking about? is it foo_coverflow_mod? if so it looks like the only way to force refresh is through keybinds and that's only if you hit F5 when that panel is focused. I was looking into some coverflow discussion here as well, to be honest the JScript version of Album Art does the job but when it comes to displaying the image it doesn't fully cover the panel unless I drag the panel borders pixel perfect to the album art. I've attached an example with red highlighting the gap. The JScript album art is set to Center.

Re: JScript Panel script discussion/help

Reply #1480
Hey, I have a problem with the fonts. The playlist organizer script shows blank squares where there shluld be symbols. I use the newest version of Jscript panel (3.5.3) and I also have the Segoe Fluent Icons installed. I also tried to change the default font for the playlist names to this new font but then everything just just those empty squares.
I tried to find a solution now for a few hours but all google tells me is that I need to install the font that is already installed :(
Any ideas? Thansk in advance ♥

Re: JScript Panel script discussion/help

Reply #1481
Well that playlist organiser is a 3rd party script, not included with the component so whatever requirements I list do not apply.

I'm guessing you need font awesome.

https://github.com/FortAwesome/Font-Awesome/raw/4.x/fonts/fontawesome-webfont.ttf


Re: JScript Panel script discussion/help

Reply #1483
@marc2k3 you asked to please use this thread for requests, so here goes. Could I have something like the following image added to your "Track Info + Spectrogram Seekbar + Buttons" script? I'll also post the current settings I am using below:



Code: [Select]
// ==PREPROCESSOR==
// @name "Track Info + Spectrogram Seekbar + Buttons"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\seekbar.js"
// ==/PREPROCESSOR==

/*
Most samples already require FontAwesome and it's used for the default buttons.
https://github.com/FortAwesome/Font-Awesome/blob/4.x/fonts/fontawesome-webfont.ttf?raw=true

The Segoe Fluent Icons font is already included with Windows 11. Windows 10 users can download it here:
https://download.microsoft.com/download/8/f/c/8fc7cbc3-177e-4a22-af48-2a85e1c5bffb/Segoe-Fluent-Icons.zip

If installed, you can right click the panel and change the button set.

---

Full ffmpeg setup instructions here: https://jscript-panel.github.io/gallery/spectrogram-seekbar/

If you edit the ffmeg_exe variable, directory separators must be escaped like "D:\\Audio\\Tools\\ffmpeg.exe"
If you edit the spectrogram_cache variable, you must make sure the folder already exists.
*/

var ffmpeg_exe = fb.ProfilePath + 'ffmpeg.exe';
var spectrogram_cache = folders.data + 'spectrogram_cache\\';

var colours = {
buttons : RGB(8, 255, 255),
background : RGB(30, 30, 30),
title : RGB(8, 255, 255),
artist : RGB(240, 240, 240),
time : RGB(240, 240, 240),
sac : RGB(196, 30, 35),
};

var tfo = {
artist : fb.TitleFormat('%artist%'),
title : fb.TitleFormat('%tracknumber% / %totaltracks% - %title%'),
playback_time : fb.TitleFormat('[%playback_time%]'),
length : fb.TitleFormat(' %length%  $ifequal(%LASTFM_LOVED_DB%,1,❤️,)' ),
};

//////////////////////////////////////////////////////////////

var panel = new _panel();
var seekbar = new _seekbar(0, 0, 0, 0, true);
var buttons = new _buttons();
var button_set_idx = 0;
var fluent_font = 'Segoe Fluent Icons';
var has_font = utils.CheckFont(fluent_font);
var bs = _scale(24);

var normal_font = CreateFontString('Segoe UI', 12);
var bold_font = CreateFontString('Segoe UI', 12, true);

window.MaxHeight = _scale(150);

var char_set = [chars, fluent_chars];

if (has_font) {
button_set_idx = window.GetProperty('2K3.BUTTON.SET', 0);
}

if (fb.IsPlaying) on_playback_new_track(fb.GetNowPlaying());
else on_item_focus_change();

buttons.update = function () {
var y = Math.round((panel.h - bs) / 2);
this.buttons.stop = new _button(panel.w - LM - (bs * 8), y, bs, bs, { char : char_set[button_set_idx].stop, colour:fb.StopAfterCurrent ? colours.sac : colours.buttons}, null, function () { fb.Stop(); }, 'Stop');
this.buttons.previous = new _button(panel.w - LM - (bs * 7), y, bs, bs, { char : char_set[button_set_idx].prev, colour:colours.buttons }, null, function () { fb.Prev(); }, 'Previous');
this.buttons.play = new _button(panel.w - LM - (bs * 6), y, bs, bs, { char : !fb.IsPlaying || fb.IsPaused ? char_set[button_set_idx].play : char_set[button_set_idx].pause, colour:colours.buttons}, null, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? 'Play' : 'Pause');
this.buttons.next = new _button(panel.w - LM - (bs * 5), y, bs, bs, { char : char_set[button_set_idx].next, colour:colours.buttons }, null, function () { fb.Next(); }, 'Next');
this.buttons.console = new _button(panel.w - LM - (bs * 3), y, bs, bs, {char : char_set[button_set_idx].console, colour:colours.buttons }, null, function () { fb.ShowConsole(); }, 'Console');
this.buttons.search = new _button(panel.w - LM - (bs * 2), y, bs, bs, { char : char_set[button_set_idx].search, colour:colours.buttons }, null, function () { fb.RunMainMenuCommand('Library/Search'); }, 'Library Search');
this.buttons.preferences = new _button(panel.w - LM - bs, y, bs, bs, { char : char_set[button_set_idx].preferences, colour:colours.buttons}, null, function () { fb.ShowPreferences(); }, 'Preferences');

if (button_set_idx == 1) {
this.change_font(fluent_font);
}
}

function on_item_focus_change() {
seekbar.item_focus_change();
}

function on_mouse_lbtn_down(x, y) {
seekbar.lbtn_down(x, y);
}

function on_mouse_lbtn_up(x, y) {
if (buttons.lbtn_up(x, y)) {
return;
}
if (seekbar.lbtn_up(x, y)) {
return;
}
fb.RunMainMenuCommand('View/Show now playing in playlist');
}

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

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

function on_mouse_rbtn_up(x, y) {
if (seekbar.containsXY(x, y)) {
return panel.rbtn_up(x, y, seekbar);
}

if (buttons.buttons.stop.containsXY(x, y)) {
fb.StopAfterCurrent = !fb.StopAfterCurrent;
return true;
}

var menu = window.CreatePopupMenu();
var sub = window.CreatePopupMenu();
sub.AppendMenuItem(MF_STRING, 1, 'Original');
sub.AppendMenuItem(EnableMenuIf(has_font), 2, 'Fluent');
sub.CheckMenuRadioItem(1, 2, button_set_idx + 1);
sub.AppendTo(menu, MF_STRING, 'Buttons');
menu.AppendMenuSeparator();
menu.AppendMenuItem(MF_STRING, 3, 'Configure');

var idx = menu.TrackPopupMenu(x, y);
menu.Dispose();

switch (idx ) {
case 1:
case 2:
button_set_idx = idx - 1;
window.SetProperty('2K3.BUTTON.SET', button_set_idx);
buttons.update();
window.Repaint();
break;
case 3:
window.ShowConfigure();
break;
}

return true;
}

function on_mouse_wheel(s) {
if (seekbar.wheel(s)) {
return;
}
if (s == 1) {
fb.VolumeUp();
} else {
fb.VolumeDown();
}
}

function on_paint(gr) {
gr.Clear(colours.background);
gr.FillRectangle(seekbar.x, seekbar.y, seekbar.w, seekbar.h, colours.seekbar_background);
seekbar.paint(gr);
DrawRectangle(gr, seekbar.x, seekbar.y, seekbar.w, seekbar.h, seekbar.properties.marker_colour.value);
buttons.paint(gr);

if (fb.IsPlaying) {
gr.WriteText(tfo.title.Eval(), bold_font, colours.title, 10, 0, seekbar.x - _scale(60), panel.h * 0.6, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);
gr.WriteText(tfo.artist.Eval(), normal_font, colours.artist, 10, panel.h * 0.3, seekbar.x - _scale(60), panel.h * 0.7, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);
gr.WriteText(tfo.playback_time.Eval(), normal_font, colours.time, seekbar.x - _scale(66), 0, _scale(60), panel.h, DWRITE_TEXT_ALIGNMENT_TRAILING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
gr.WriteText(tfo.length.Eval(), normal_font, colours.time, seekbar.x + seekbar.w + _scale(6), 0, _scale(60), panel.h, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
}
}

function on_playback_dynamic_info_track(type) {
if (type == 0) window.Repaint();
}

function on_playback_edited() {
window.Repaint();
}

function on_playback_new_track(metadb) {
seekbar.playback_new_track(metadb);
}

function on_playback_pause() {
buttons.update();
window.Repaint();
}

function on_playback_seek() {
seekbar.playback_seek();
}

function on_playback_starting() {
buttons.update();
window.Repaint();
}

function on_playback_stop(reason) {
seekbar.playback_stop(reason);
buttons.update();
window.Repaint();
}

function on_playback_time() {
window.RepaintRect(panel.h, 0, seekbar.x - panel.h, panel.h);
}

function on_playlist_stop_after_current_changed() {
buttons.update();
window.Repaint();
}

function on_playlist_switch() {
seekbar.item_focus_change();
}

function on_run_cmd_async_done(task_id) {
seekbar.run_cmd_async_done(task_id);
}

function on_size() {
panel.size();
seekbar.x = _scale(300);
seekbar.y = _scale(5);
seekbar.w = panel.w - seekbar.x - _scale(280);
seekbar.h = panel.h - (seekbar.y * 2);
buttons.update();
}


Re: JScript Panel script discussion/help

Reply #1485
thx. And another quick question, how do you actually show brackets (like the actual characters) in a format string

Re: JScript Panel script discussion/help

Reply #1486
First update code like this...

Code: [Select]
fb.TitleFormat('%album%')

to use double quotes..

Code: [Select]
fb.TitleFormat("%album%")

Now you can use single quotes around [] or ()

Code: [Select]
fb.TitleFormat("%album% '('%date%')'")

Re: JScript Panel script discussion/help

Reply #1487
I've added full $rgb support to the following samples, They can be tested by pasting the contents of these links in a panel.

Track Info + Seekbar + Buttons + Volume
https://raw.githubusercontent.com/jscript-panel/component/main/samples/Track%20Info%20%2B%20Seekbar%20%2B%20Buttons%20%2B%20Volume.txt

Track Info + Seekbar + Buttons
https://raw.githubusercontent.com/jscript-panel/component/main/samples/Track%20Info%20%2B%20Seekbar%20%2B%20Buttons.txt

Track Info + Spectrogram Seekbar + Buttons
https://raw.githubusercontent.com/jscript-panel/component/main/samples/Track%20Info%20%2B%20Spectrogram%20Seekbar%20%2B%20Buttons.txt

Re: JScript Panel script discussion/help

Reply #1488
Something curious happens with the Text Display sample. If I play a track, then change the playlist and then press Stop, the text displayed changes to "NEIN". This happens either by selecting a different playlist or by changing the Library Viewer Selection playlist with Album List, Refacets etc.
Using JScript Panel 3.5.2 on foobar2000 v2.2 preview 2024-05-17 x64.

Re: JScript Panel script discussion/help

Reply #1489
I know how that error can occur but I thought I had safeguards to prevent it.

Can you try saving this file inside your component folder\samples\js overwriting the existing file.

https://raw.githubusercontent.com/jscript-panel/component/main/samples/js/text_display.js

Restart fb2k if it's running.

Re: JScript Panel script discussion/help

Reply #1490
@marc2k3 :
Yes, replacing the file has fixed the issue for me, thanks.

Re: JScript Panel script discussion/help

Reply #1491
Message to marc2k3:

Until now I used cover-info to detect in a playlist the albums that I had forgotten to embed their cover.
First I would run the "Scan for cover info" option in the playlist
And then I ran in Re-Facets the filter %front_cover_width% MISSING that returned me the tracks that didn't have the cover embedded.
Everything worked perfectly.

I uninstalled
   - foo_cover_info-1.0.4.fb2k-component
   - foo_cover_resizer-1.0.8.fb2k-component

I have installed foo_cover_utils-1.0.fb2k-component
And it doesn't work anymore. The Re-Facets gives me back all the discs in the playlist when they all have their cover embedded.

I had to uninstall it and reinstall foo_cover_info and foo_cover_resizer.
I don't know if there's something I'm not doing right or if the new component is not fully adjusted.

 

Re: JScript Panel script discussion/help

Reply #1492
This is entirely the wrong thread to ask about this. :/

Anyway... the download page did have a broken link which I've just fixed. Sorry to everyone about that.

It should have told you to read here...

https://marc2k3.github.io/component/cover-utils/
Quote
This is a combined replacement for foo_cover_info and foo_cover_resizer. If you have either/both installed, you must remove them first.

Note that this uses a separate database for front cover info storage so files would need scanning again. Also, different title format fields are used for display. See below.

specifically...

https://marc2k3.github.io/component/cover-utils/#scan-for-info

Re: JScript Panel script discussion/help

Reply #1493
This is entirely the wrong thread to ask about this. :/

Anyway... the download page did have a broken link which I've just fixed. Sorry to everyone about that.

It should have told you to read here...

https://marc2k3.github.io/component/cover-utils/
Quote
This is a combined replacement for foo_cover_info and foo_cover_resizer. If you have either/both installed, you must remove them first.

Note that this uses a separate database for front cover info storage so files would need scanning again. Also, different title format fields are used for display. See below.

specifically...

https://marc2k3.github.io/component/cover-utils/#scan-for-info

Thanks Marc.

I just had to replace in Re-Facets the filter %front_cover_width% MISSING  by  %cover_utils_front_width% MISSING

Everything works perfect

Re: JScript Panel script discussion/help

Reply #1494
Drag-and-drop for tracks in Smooth Playlist seems not to be working for me in 3.5.5.  :'(
I'm sure it was OK in the last couple of versions...

Re: JScript Panel script discussion/help

Reply #1495
Drag/drop in Smooth Playlist it extremely limited. You can drag/drop from other panels on to it and that is all. No matter where you let go of the mouse, the selection is always appended to the end. There is no placement. The current version is working fine in that regard.

JS Playlist is the one with full drag/drop support.

BTW, the mouse pointer should indicate if drag/drop is totally prohibited due to an autoplaylist or other playlist lock preventing the addition of new items.

Re: JScript Panel script discussion/help

Reply #1496
Ah, of course! Sorry for wasting your time.

Re: JScript Panel script discussion/help

Reply #1497
hi
I have a minor question about displaying Properties.

If the panel size is limited, long tag field names will make the field values ​​almost invisible.
XX

Is it possible to adjust the size as shown below or omit the part before keywords such as "MUSICBRAINZ_"?
X
X
X

Re: JScript Panel script discussion/help

Reply #1498
Save this in your component folder\samples\js overwriting the existing file.

https://raw.githubusercontent.com/jscript-panel/component/main/samples/js/list.js

It will also be in the next component release whenever that is.

Re: JScript Panel script discussion/help

Reply #1499
It's easier to see
Thank you!