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 283091 times) previous topic - next topic
IP974 and 2 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #875
Very strange! You can see from the screenshot that Foobar2000 shows .jxl files. I have these files in the spectrogram_cache folder, but they are not shown in the player itself. I installed jxl-winthumb, in other programs, jxl pictures began to be displayed after installing it. But not in Foobar2000.

Re: JScript Panel script discussion/help

Reply #876
Several megabytes for each file, about 80% of its weight, while the files themselves can be hundreds or thousands.
That's your own problem!  Maybe instead of
jxl is much better, please use it.
...you actually meant "please make jxl available as an option".
It's your privilege to disagree, but that doesn't make you right and me wrong.

Re: JScript Panel script discussion/help

Reply #877
But not in Foobar2000.

Not sure if you're talking about this component or foobar2000 in general??

fb2k itself has only been able to display jxl (and other exotic codecs) since v2 was released nearly 2 weeks ago.

As for my component, only foo_jscript_panel3 can do it. The was released back in April I think. The original foo_jscript_panel can not.

All this comes from utilising the windows imaging component (WIC). The C++ code is entirely generic and has no idea about what codecs you have installed. While the JSP3 source code is not online, I have another component which uses WIC and you can see the code is just a few lines here...

https://github.com/marc2k3/foo_cover_resizer/blob/51776f5480ad72e6a255fa1f955a5d61bba33cc7/src/Helpers.hpp#L7L16





Re: JScript Panel script discussion/help

Reply #878
Thanks for letting me know about the beta! On the beta version, jxl works for me too.
Now I will look for a way to transfer my settings from the stable version to the beta. Copying the profile folder results in an error at startup.

Re: JScript Panel script discussion/help

Reply #879
You can use v3.0.3 of my component with fb2k v1.5/1.6.

The album art sample can display .jxl files if you manually add .jxl under File>Preferences>Display>Album Art. Wildcards are not supported like they are for common types like jpg/png/etc

The thumbs sample for displaying multiple images will not display jxl files by default but the script can be edited, After the second line...

Code: [Select]
var thumbs = new _thumbs();

Add

Code: [Select]
thumbs.exts.push('jxl');



Re: JScript Panel script discussion/help

Reply #880
I am using jscript panel version number 3.03 on foobar version 1.6.7. .jxl doesn't work in this version, but it opens in Foobar2000 beta. And only with 64-bit architecture. But the plugins I need are not available for the 64-bit architecture, they only work in the 32-bit beta version, on which jxl does not work for me. Some kind of curse.
I don't know about any miniatures or album covers.


Re: JScript Panel script discussion/help

Reply #882
Do you have any ideas how to fix this? Add 64bit plugin support to 32bit foobar.


Re: JScript Panel script discussion/help

Reply #884
I am asking for the favor of a JScript Panel 3 script that would take simple "now playing" information from Foobar v2 64-bit and write it to an external text file, appending lines within the file as each song is played to a specified limit (lines or file size).  The information would be the date/time played and the <artist> - <title> information from the track, from either dynamic radio station metadata or fixed files.  Nothing would need to be kept in a DB, just written into the text file appending each track while Foobar is in use.  Thanks for any help you can provide.

Re: JScript Panel script discussion/help

Reply #885
I am asking for the favor of a JScript Panel 3 script that would take simple "now playing" information from Foobar v2 64-bit and write it to an external text file, appending lines within the file as each song is played to a specified limit (lines or file size).  The information would be the date/time played and the <artist> - <title> information from the track, from either dynamic radio station metadata or fixed files.  Nothing would need to be kept in a DB, just written into the text file appending each track while Foobar is in use.  Thanks for any help you can provide.

This will do it in the background, nothing is displayed in the panel.
Set maxfilesize to your preferred limit (the value is in bytes)

Code: [Select]
var myhistory = fb.ProfilePath + "myhistory.txt";
var maxfilesize = 5242880; //5MB in bytes

if (utils.IsFile(myhistory) == false) {
    utils.WriteTextFile(myhistory, "");
}

function save_history() {
    var fsize = utils.GetFileSize(myhistory);
    if (fsize < maxfilesize) {
        var strContents = utils.ReadTextFile(myhistory);
    } else {
        strContents = "";
    }
var now = Math.round(new Date().getTime() / 1000);
    var artist = fb.TitleFormat("%artist%").Eval();
    var title = fb.TitleFormat("%title%").Eval();
    var strNewContents = strContents + "\n" + "[" + utils.TimestampToDateString(now) + "]  " + artist + " - " + title;
    if (artist && title) {
        utils.WriteTextFile(myhistory, strNewContents);
    }
}

function on_playback_new_track() {
    save_history();
}

function on_playback_dynamic_info_track() {
    save_history();
}

Re: JScript Panel script discussion/help

Reply #886
@zeremy

Code: [Select]
function on_playback_dynamic_info_track() {
    save_history();
}

That code might log double entries depending on stream. Since fb2k v1.6.6 came out with support for album art from radio streams, I updated that callback to supply a type argument. It has a value of 0 for metadata updates and 1 for album art updates.

https://marc2k3.github.io/jscript-panel/docs/callbacks/#on_playback_dynamic_info_tracktype
https://marc2k3.github.io/jscript-panel/docs/interfaces/IMetadbHandle/#getalbumartart_id-want_stub

To avoid duplication...

Code: [Select]
function on_playback_dynamic_info_track(type) {
    if (type == 0) save_history();
}



Re: JScript Panel script discussion/help

Reply #888
Thanks zeremy and marc2k3 for the scripts!

From the start I used marc2k3's replacement for the dynamic info.  For fixed music files all works perfect, but for stream track metadata I am seeing doubling (but single in 3 cases) and occasionally tripling of artist/titles lines, and occasionally the station names preceded by a "?" in the artist field.  Sample log below.  Station changes were made by double-clicking a new stream as opposed to hitting stop first.  Any way to fix this?

[2022-09-27 16:28:29]  ? - Decennial Gothica Radio I
[2022-09-27 16:28:29]  ? - Decennial Gothica Radio I
[2022-09-27 16:28:30]  Pain - Dirty Woman
[2022-09-27 16:28:36]  Arcana Elysium - Cold Road
[2022-09-27 16:28:36]  Arcana Elysium - Cold Road
[2022-09-27 16:28:42]  Sirenia - In a maniac
[2022-09-27 16:28:42]  Sirenia - In a maniac
[2022-09-27 16:29:09]  ? - Pangea
[2022-09-27 16:29:09]  ? - Pangea
[2022-09-27 16:29:11]  To Die For - Sorrow Remains
[2022-09-27 16:29:17]  Fleetwood Mac - Little Lies (Extended Remix)
[2022-09-27 16:29:18]  Fleetwood Mac - Little Lies (Extended Remix)
[2022-09-27 16:29:29]  Nikola Iliev - Save Me (Original Mix)
[2022-09-27 16:29:30]  Nikola Iliev - Save Me (Original Mix)
[2022-09-27 16:29:30]  Nikola Iliev - Save Me (Original Mix)
[2022-09-27 16:30:13]  Duran Duran - The Chauffeur [qdI]
[2022-09-27 16:30:13]  Duran Duran - The Chauffeur [qdI]
[2022-09-27 16:30:37]  Cairo Gang - Ice Fishing
[2022-09-27 16:30:37]  Cairo Gang - Ice Fishing
[2022-09-27 16:30:38]  Cairo Gang - Ice Fishing
[2022-09-27 16:30:45]  Lettie - Never Want To Be Alone
[2022-09-27 16:30:45]  Lettie - Never Want To Be Alone
[2022-09-27 16:30:45]  Lettie - Never Want To Be Alone
[2022-09-27 16:30:53]  ? - Lush: Mostly female vocals with an electronic influence. [SomaFM]
[2022-09-27 16:30:53]  ? - Lush: Mostly female vocals with an electronic influence. [SomaFM]
[2022-09-27 16:30:53]  Schiller - Sunrise





Re: JScript Panel script discussion/help

Reply #889
Well the callback responsible is getting more notifications than you would expect and that can only come from the server.

This should workaround it by not logging any consecutive duplicates.

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// ==/PREPROCESSOR==

var limit = 100;
var tfo = fb.TitleFormat("[%artist% - ]%title%");
var path = "Z:\\fb2k_log.txt";

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

var last = '';

function on_playback_new_track() {
log_it();
}

function on_playback_dynamic_info_track(type) {
if (type == 0) {
log_it();
}
}

function now_as_string() {
var now = Math.floor(Date.now() / 1000);
return utils.TimestampToDateString(now);
}

function log_it() {
var current = tfo.Eval();
if (current != last) {
last = current;

var text = utils.ReadUTF8(path);
var arr = _(text.trim().split("\r\n"))
.filter(function (item) { return item.length > 0; })
.takeRight(limit - 1)
.value();
arr.push(now_as_string() + " " + current);
utils.WriteTextFile(path, arr.join("\r\n"));
}
}

Re: JScript Panel script discussion/help

Reply #890
Thanks marc2k3 for the new script!  This one works great, no doubles, just the station name on one line followed by the track played on the next.  I really appreciate it.  BTW, can you confirm what the "var limit" number refers to (lines or file size), and if when the limit is reached the log will "scroll delete" the oldest entry from the top of the list?

I listen to a lot of Interent radio and sometimes I hear a song I want to refer back to but forgot the track artist/title; this log feature is perfect for helping to recall it.


Re: JScript Panel script discussion/help

Reply #892
OK, thanks!

Re: JScript Panel script discussion/help

Reply #893
Hi all,
I have this abstract of a script below that executes correctly when foobar is running but if i'm closing foobar and opening it again, this code crashes at line 18 ie :
Code: [Select]
img = utils.CreateImage(window.Width, 40);
Anyone would know why ?
Thanks in advance
Code: [Select]
// ==PREPROCESSOR==
// @name "StackBlur (text)"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// ==/PREPROCESSOR==

var colour = RGB(129, 166, 192);
var img = null;
var g_font = JSON.stringify({
Name : "Segoe UI",
Size : 32,
Weight : 700,
});

create_image();

function create_image() {
img = utils.CreateImage(window.Width, 40);
var g = img.GetGraphics();
    text_to_draw = "FB";
g.WriteText(text_to_draw, g_font, colour, 150, 0, 40,40, 2, 2, 1, 1);
img.ReleaseGraphics();
g=null;
}


Re: JScript Panel script discussion/help

Reply #895
Thanks Marc,
It's true that while i'm reading your docs extensively, this tips section, i may have read it only once !

Still, i cant make it to work.
This is what i've done and now the
Code: [Select]
img = utils.CreateImage(ww, 40);
line raises an error, which is understandable as i'm not resizing the window at startup.

Code: [Select]
// ==PREPROCESSOR==
// @name "StackBlur (text)"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// ==/PREPROCESSOR==

var colour = RGB(129, 166, 192);
var img = null;
var ww;
var g_font = JSON.stringify({
Name : "Segoe UI",
Size : 32,
Weight : 700,
});

create_image();

function create_image() {
img = utils.CreateImage(ww, 40);
var g = img.GetGraphics();
    text_to_draw = "FB";
g.WriteText(text_to_draw, g_font, colour, 150, 0, 40,40, 2, 2, 1, 1);
img.ReleaseGraphics();
g=null;
}

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

Re: JScript Panel script discussion/help

Reply #896
on_size is always called as part of the script initialisation process but that doesn't happen until any code not inside any function has run first.

But since you want the image based on the panel width, you should call create_image() from inside on_size like this.

Code: [Select]
var img = null;
var ww = 0;
// create_image(); // remove this.

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

function create_image() {
if (img) img.Dispose();
img = utils.CreateImage(ww, 40);
var g = img.GetGraphics();
text_to_draw = "FB";
g.WriteText(text_to_draw, g_font, colour, 150, 0, 40,40, 2, 2, 1, 1);
img.ReleaseGraphics();
g=null;
}

Re: JScript Panel script discussion/help

Reply #897
and this solves it perfectly !

Thanks for your continued support Marc !

Ps : If i wanted to understand the on_size behavior (the fact it runs after a code not within a function has executed), would you have any pointers ?

Re: JScript Panel script discussion/help

Reply #898
Only code outside any function is run when the script parser evaluates the script. You can of course have your own 10,000 line function and call that. Assuming there are no errors during that phase, nothing would ever happen without callbacks sent by the component.

So the first thing that happens is that on_size is called. This has to be faked because if you're editing the script and clicking OK/Apply in the config window, that is not a cause for the panel to be resized. And when on_size is done, on_paint comes next.

After that, it depends entirely on the callbacks you include in the script and the actions you make on the panel and fb2k events such as playback starting/stopping etc. All that is documented on the callbacks page.

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

I should update the entry for on_size to make it clearer what happens on startup.


Re: JScript Panel script discussion/help

Reply #899
alright, it's clearer. Thanks !