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

Re: JScript Panel script discussion/help

Reply #1150
The component already exposes 10 main menu commands and you can use them for your needs.

https://jscript-panel.github.io/docs/callbacks/#on_main_menuindex

Your code inside the callback can make it function like a context menu item...

(not tested as I don't have a fb2k instance with me right now but you get the idea)

Code: [Select]
function on_main_menu(index) {
if (index >= 1 && index <= 5) {
var items = fb.GetSelection(); // should work with playlist or library viewer selections
if (items.Count == 0) return;

for (var i = 0; i < items.Count; i++) {
items.GetItem(i).SetRating(index);
}
items.RefreshStats();
}

// use one the remaining indexes for setting zero rating or whatever.
}


     

Re: JScript Panel script discussion/help

Reply #1151
This is the script I modified from samples. Now I want to make the slider display at the start position of the seekbar and display "0:00" on both sides of the seekbar after the playback stops

Inside on_paint, there is this...

Code: [Select]
if (fb.IsPlaying) {
...
}

Just add an else like...

Code: [Select]
if (fb.IsPlaying) {
...
} else {
gr.WriteText("0:00", bold_font, colours.time, seekbar.x - _scale(51), (panel.h - _scale(12)) / 2, _scale(45), _scale(12), DWRITE_TEXT_ALIGNMENT_TRAILING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
gr.WriteText("0:00", bold_font, colours.time, seekbar.x + seekbar.w + _scale(12), (panel.h - _scale(12)) / 2, _scale(45), _scale(12), DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
}

Re: JScript Panel script discussion/help

Reply #1152
The component already exposes 10 main menu commands and you can use them for your needs.

https://jscript-panel.github.io/docs/callbacks/#on_main_menuindex

Your code inside the callback can make it function like a context menu item...

(not tested as I don't have a fb2k instance with me right now but you get the idea)

Code: [Select]
function on_main_menu(index) {
if (index >= 1 && index <= 5) {
var items = fb.GetSelection(); // should work with playlist or library viewer selections
if (items.Count == 0) return;

for (var i = 0; i < items.Count; i++) {
items.GetItem(i).SetRating(index);
}
items.RefreshStats();
}

// use one the remaining indexes for setting zero rating or whatever.
}


     

My bad, I'm sorry for not checking the documentation... However, Thanks a lot for implementing so many features! was about to lose hope and move to MusicBee until you implemented the new feature.

Re: JScript Panel script discussion/help

Reply #1153
The component already exposes 10 main menu commands and you can use them for your needs.

https://jscript-panel.github.io/docs/callbacks/#on_main_menuindex

Your code inside the callback can make it function like a context menu item...

(not tested as I don't have a fb2k instance with me right now but you get the idea)

Code: [Select]
function on_main_menu(index) {
if (index >= 1 && index <= 5) {
var items = fb.GetSelection(); // should work with playlist or library viewer selections
if (items.Count == 0) return;

for (var i = 0; i < items.Count; i++) {
items.GetItem(i).SetRating(index);
}
items.RefreshStats();
}

// use one the remaining indexes for setting zero rating or whatever.
}


     

Hello @marc2k3 I guess I've found a bug with the above code... Here is my implementation so far.
Code: [Select]
function on_main_menu(index) {
switch (index) {
case 1:
var handle_list = plman.GetPlaylistSelectedItems(plman.ActivePlaylist); // I've tried var items = fb.GetSelection(); as well but still the same result.
if (handle_list.Count == 0) return;
if (fb.GetSelectionType() != 1) return;
var tfo = fb.TitleFormat("%jsp3_loved%");
var favourites = tfo.EvalWithMetadbs(handle_list).toArray();
for (var i = 0; i < handle_list.Count; i++) {
if (favourites[i] === "1") handle_list.GetItem(i).SetLoved(0);
else handle_list.GetItem(i).SetLoved(1);
}
handle_list.RefreshStats();
break;
}
}

I have a playlist of 604 tracks selected and on properties tab shows the same...

Upon applying the function and checking the properties tab there are 645 tracks? Around 41 duplicate tracks made in when applying the setLoved function...

Upon further inspecting the playlist of the correct and wrong tracks I've found out it's duplicates with the same track name but different albums.

I've attached images for you to look into. The left playlist is the correct playlist and the right playlist is wrong, You can see how there are entries added in the right playlist but weren't there to begin with in the left playlist.

Re: JScript Panel script discussion/help

Reply #1154
This is the script I modified from samples. Now I want to make the slider display at the start position of the seekbar and display "0:00" on both sides of the seekbar after the playback stops

Inside on_paint, there is this...

Code: [Select]
if (fb.IsPlaying) {
...
}

Just add an else like...

Code: [Select]
if (fb.IsPlaying) {
...
} else {
gr.WriteText("0:00", bold_font, colours.time, seekbar.x - _scale(51), (panel.h - _scale(12)) / 2, _scale(45), _scale(12), DWRITE_TEXT_ALIGNMENT_TRAILING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
gr.WriteText("0:00", bold_font, colours.time, seekbar.x + seekbar.w + _scale(12), (panel.h - _scale(12)) / 2, _scale(45), _scale(12), DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
}

Thanks Marc for your help. I added your code but not getting the expected result. Hope to get your help again.
Below is the result I want.

Re: JScript Panel script discussion/help

Reply #1155
Upon further inspecting the playlist of the correct and wrong tracks I've found out it's duplicates with the same track name but different albums.

I've been explicit about this. An earlier comment in this thread before I released the component:

Quote
The one major flaw in previous implementations is that the title formatting was hard coded to %artist% - %title%. All I cared about was storing last.fm stats which worked well for me but it was probably less useful for everyone else. The new version is entirely configurable. But any changes to the title format will wipe all previous data. It has to be used with care!

When I announced the component release in the main thread:

Quote
Playback statistics are back. The title format pattern for binding database records to tracks is no longer hard coded. It can edited to anything you like.

If you missed that, the changelog and release page included this:

Code: [Select]
https://jscript-panel.github.io/docs/playback-statistics/

Read with care. Behaviour and functionality has changed since the previous implementation in JScript Panel 2.

Specifically...

Quote
Unlike previous implementaions in other scripting components, this allows you to customise the title formatting that database records are bound to.

The default is $lower($meta(artist,0) - %title%) but it can be changed via File>Preferences>Advanced>Tools>JScript Panel 3>Playback Statistics Title Format.

Note that changing this requires an immediate foobar2000 restart and any previously saved data is lost forever. Be careful!

Remember that if you think of using %path%, you must also include %subsong%. One physical file can have the same path for multiple handles if it's a cuesheet or other type of track with multiple chapters.

You can grumble all you like about me using a crappy default but I'm not apologising to anyone who doesn't read or did read it but doesn't understand the premise.



Re: JScript Panel script discussion/help

Reply #1156
Upon further inspecting the playlist of the correct and wrong tracks I've found out it's duplicates with the same track name but different albums.

I've been explicit about this. An earlier comment in this thread before I released the component:

Quote
The one major flaw in previous implementations is that the title formatting was hard coded to %artist% - %title%. All I cared about was storing last.fm stats which worked well for me but it was probably less useful for everyone else. The new version is entirely configurable. But any changes to the title format will wipe all previous data. It has to be used with care!

When I announced the component release in the main thread:

Quote
Playback statistics are back. The title format pattern for binding database records to tracks is no longer hard coded. It can edited to anything you like.

If you missed that, the changelog and release page included this:

Code: [Select]
https://jscript-panel.github.io/docs/playback-statistics/

Read with care. Behaviour and functionality has changed since the previous implementation in JScript Panel 2.

Specifically...

Quote
Unlike previous implementaions in other scripting components, this allows you to customise the title formatting that database records are bound to.

The default is $lower($meta(artist,0) - %title%) but it can be changed via File>Preferences>Advanced>Tools>JScript Panel 3>Playback Statistics Title Format.

Note that changing this requires an immediate foobar2000 restart and any previously saved data is lost forever. Be careful!

Remember that if you think of using %path%, you must also include %subsong%. One physical file can have the same path for multiple handles if it's a cuesheet or other type of track with multiple chapters.

You can grumble all you like about me using a crappy default but I'm not apologising to anyone who doesn't read or did read it but doesn't understand the premise.




My bad, haven't understood what it fully meant, but it'd definitely fix my issue of duplicate tracks by using path and subsong...

Also is it possible to have a skip field like how we have for play count or would that complicate things up? Would be nice to have skip statistics so that the user knows track ABC has been presented X times and skipped Y times?


Re: JScript Panel script discussion/help

Reply #1158
I'm not totally averse to adding more fields but foo_skip and foo_skipcount provide that already.

It's just that it would be better to have all of them in one plugin that way the user can customise the logic behind what counts as a play or a skip...

Re: JScript Panel script discussion/help

Reply #1159
Hi there,

I am new to JScript Panel.
I installed the latest version, and used the sample "Text Display" (as-is, it is not modified).

I see this small square box at the bottom of the panel.
When I click the square box, it goes to the top of the panel.
Any idea how to get rid of it?



Re: JScript Panel script discussion/help

Reply #1161
^ It would be great to have an option (or pointer to modify the code) to disable those scroll arrows though, because the trouble is when you only want a small 20px height panel, all you get are arrows and no text. (At least that was the case last time I used it)


Re: JScript Panel script discussion/help

Reply #1163
^ It would be great to have an option (or pointer to modify the code) to disable those scroll arrows though, because the trouble is when you only want a small 20px height panel, all you get are arrows and no text. (At least that was the case last time I used it)

I'll remove them in the next release.

edit: code has been updated on github. If anyone wants it right now, save this inside your component folder\samples\js

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


Re: JScript Panel script discussion/help

Reply #1165
If possible in the next version of Text Display add the option Album Art bottom, Text top, at the moment I had to add an additional sample panel to recreate the effect as shown in the images:




Re: JScript Panel script discussion/help

Reply #1166
By the way marc2k3, I feel like someone has mentioned this before but is it possible to have JSPlaylist imitate how SimPlaylists work? It will be a really great addition for users who want to switch from SimPlaylists as it's an old component and hasn't been updated so the white borders and bars are really visible in FB2K 2.0, The only two features which are missing are Sub-groups and positioning the album art cover to the left of the tracks apart from that JSPlaylist seems to be very close to replicating SimPlaylists...

If I recollect a WSH Panel version of JSPlaylist had the option to display album art cover to the left of the tracks. I've attached three images including the one with the WSH Panel taken from a Reddit post...

Re: JScript Panel script discussion/help

Reply #1167
By the way marc2k3, I feel like someone has mentioned this before but is it possible to have JSPlaylist imitate how SimPlaylists work? It will be a really great addition for users who want to switch from SimPlaylists as it's an old component and hasn't been updated so the white borders and bars are really visible in FB2K 2.0, The only two features which are missing are Sub-groups and positioning the album art cover to the left of the tracks apart from that JSPlaylist seems to be very close to replicating SimPlaylists...

If I recollect a WSH Panel version of JSPlaylist had the option to display album art cover to the left of the tracks. I've attached three images including the one with the WSH Panel taken from a Reddit post...
This problem you raise has been my struggle since I installed foobar many years ago. I am referring to the management of groups.

A long time ago, when I was working with Default UI I installed Simplaylist, which has been the playlist manager that I liked the most when it came to grouping albums with several discs. I remember that the only thing that I didn't like was the line that it drew when painting the %discnumber% metadata to the right since it was enough to frame the album the line that was painted in the abum. I think I could not remove it as I was very limited when programming scripts.

Then I installed Columns UI which is more customizable. After creating different scripts I got the current look (Image) which is not perfect either as I don't like that the grouping that deals with the %discnumber% does not allow painting to the right of the cover and does it on top. I have been asking for years to music music that is its creator, but until today I have not obtained it. Even so the appearance of albums with several discs looks pretty good, at least it's the best I could program. I recommend you to install it and try it.

The right panel showing the covers with their most important data is made from the JsPlaylist before Marc2k3 decided to remove the collapsing of the albums. 

Re: JScript Panel script discussion/help

Reply #1168
Then I installed Columns UI which is more customizable. After creating different scripts I got the current look (Image) which is not perfect either as I don't like that the grouping that deals with the %discnumber% does not allow painting to the right of the cover and does it on top. I have been asking for years to music music that is its creator, but until today I have not obtained it. Even so the appearance of albums with several discs looks pretty good, at least it's the best I could program. I recommend you to install it and try it.
 

Hey there! Thanks for sharing your insight, just few days ago a friend of mine also showcased me his CUI theme and it caught me by surprise...

Spending my weekend setting up CUI only to release at the end of today that all my efforts are in vain as resizing in CUI wasn't viable with my theming which consists of Spider Monkey and a JScript 3 panel, my layout basically couldn't scale properly when minimised or on fullscreen and I've exhausted all options such as locking layouts and etc. but that didn't resolve the issue to any degree.

This ultimately made me go back to DUI... Now, about JSPlaylist the in-built Playlist Manager/Organizer which is tucked in a small arrow mark looks neat and subtle. It will definitely be a nice to have if JSPlaylist could imitate SimPlaylist to some extent while giving the user the option to do so within the JSPlaylist's option panel.

Re: JScript Panel script discussion/help

Reply #1169
Then I installed Columns UI which is more customizable. After creating different scripts I got the current look (Image) which is not perfect either as I don't like that the grouping that deals with the %discnumber% does not allow painting to the right of the cover and does it on top. I have been asking for years to music music that is its creator, but until today I have not obtained it. Even so the appearance of albums with several discs looks pretty good, at least it's the best I could program. I recommend you to install it and try it.
 

Hey there! Thanks for sharing your insight, just few days ago a friend of mine also showcased me his CUI theme and it caught me by surprise...

Spending my weekend setting up CUI only to release at the end of today that all my efforts are in vain as resizing in CUI wasn't viable with my theming which consists of Spider Monkey and a JScript 3 panel, my layout basically couldn't scale properly when minimised or on fullscreen and I've exhausted all options such as locking layouts and etc. but that didn't resolve the issue to any degree.

This ultimately made me go back to DUI... Now, about JSPlaylist the in-built Playlist Manager/Organizer which is tucked in a small arrow mark looks neat and subtle. It will definitely be a nice to have if JSPlaylist could imitate SimPlaylist to some extent while giving the user the option to do so within the JSPlaylist's option panel.
I have to tell you that I made several queries to Marc2k3 when I set up my 64-bit foobar2000. I was testing JsPlaylist to see if I liked the groupings. But I didn't like them and I made several requests and he answered me that the component was an inheritance of Br3tt and that he didn't plan to make improvements. 

Re: JScript Panel script discussion/help

Reply #1170
I have to tell you that I made several queries to Marc2k3 when I set up my 64-bit foobar2000. I was testing JsPlaylist to see if I liked the groupings. But I didn't like them and I made several requests and he answered me that the component was an inheritance of Br3tt and that he didn't plan to make improvements. 


Ah fair enough, unfortunately I don't think CUI would be a viable option for me yet due to the issue I've mentioned above but apart from that I guess I'm left with nothing on table...

Re: JScript Panel script discussion/help

Reply #1171
I'm never going back on the changes I've made to JSPlaylist. If anyone doesn't like it, don't use it. It really is that simple.

And subgroups are never going to happen. Anyone can transplant the jsplaylist folder from the component folder to somewhere else where it will untouched by component upgrades and make their own changes.

Re: JScript Panel script discussion/help

Reply #1172
By the way marc2k3, is it possible in JSPlaylist > Colours > Text to separate this header section alone and name it as Highlight? Similar to how foobar2000 has a colour section for Text and Highlight separately in Colors and Font?

Re: JScript Panel script discussion/help

Reply #1173
By the way marc2k3, is it possible in JSPlaylist > Colours > Text to separate this header section alone and name it as Highlight? Similar to how foobar2000 has a colour section for Text and Highlight separately in Colors and Font?

Try this one. Copy and replace the files into your jsplaylist folder. Mine is on
C:\Users\Username\AppData\Roaming\foobar2000-v2\user-components\foo_jscript_panel3\samples\jsplaylist



Re: JScript Panel script discussion/help

Reply #1174
Try this one. Copy and replace the files into your jsplaylist folder. Mine is on
C:\Users\Username\AppData\Roaming\foobar2000-v2\user-components\foo_jscript_panel3\samples\jsplaylist




Hey, thanks a lot for sharing your patches! I've also noticed you in the DUI Gallery forum post, but to reconfirm for the JS playlist, are you using FontAwesome? or is it a custom font?