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 308262 times) previous topic - next topic
0 Members and 1 Guest 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