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 290764 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #1400
I tried, but It doesn't work.
A little hard to tell you why without the corresponding code - you just defined some variables...
[attach type=image]29696[/attach]

Like this?

RDIT: Try the attached script

It works perfectly. Thanks. 👍👍
The _button_mir function allows, among other things, to assign the "Material Icons Round" font to the plmanager button. 👍
[/quote]

Good!

Modifications were a bit sloppy so I've updated the script to make it more generic.

I dropped the '_button_mir' function and created a more generic function '_button_mod' that accepts an optional fontname (default Segoe Fluent Icons) and optional fontsize offset (defaults to 10). Basically you can any font for buttons you like.
All buttons use the same function now. And as a result the RG button is slightly larger and more in line with the other buttons.
I also implemented the last changes from the standard script so the seekbar aligns nicely.

Have a look ...

EDIT: Some last oops additions - Use script v7a

Re: JScript Panel script discussion/help

Reply #1401
Quote
Modifications were a bit sloppy so I've updated the script to make it more generic.

I dropped the '_button_mir' function and created a more generic function '_button_mod' that accepts an optional fontname (default Segoe Fluent Icons) and optional fontsize offset (defaults to 10). Basically you can any font for buttons you like.
All buttons use the same function now. And as a result the RG button is slightly larger and more in line with the other buttons.
I also implemented the last changes from the standard script so the seekbar aligns nicely.

Have a look ...

EDIT: Some last oops additions - Use script v7a

Works perfectly. 👍👍 I've added somme buttons.
With _button_mod function, you can easily add what you want as char, in any font. 👍👍.Thanks a lot.

X

Re: JScript Panel script discussion/help

Reply #1402
X

When there is no image display (this certainly concerns albumart.js), would it be possible to indicate this absence with an image, for example :

X

Re: JScript Panel script discussion/help

Reply #1403
File>Preferences>Display>Album Art>Artist tab>Stub image.

edit: That was for the original album art script. Text display only supports Front so configure the stub image under that tab.

Re: JScript Panel script discussion/help

Reply #1404
File>Preferences>Display>Album Art>Artist tab>Stub image.

edit: That was for the original album art script. Text display only supports Front so configure the stub image under that tab.

The following question is NOT about the modified Text Display + Album Art + Seekbar + Buttons.txt, but rather about the standard Album Art.txt where mousewheel is supported.

Since there is no way to enter a stub image for Icon can you please reconsider making a stub available for icon in your settings (something like 2K3.ARTREADER.ICON.STUB)?

NB. I was able to skip Icon on mousewheel altogether by adding one line to _albumart, but I rather have a decent solution since in rare cases there actually is an icon image added to the audiofile.

Re: JScript Panel script discussion/help

Reply #1405
File>Preferences>Display>Album Art>Artist tab>Stub image.

edit: That was for the original album art script. Text display only supports Front so configure the stub image under that tab.

Is it possible to take into account the absence of certain images in albumart.js? (back.jpg, cd.jpg, artist.jpg, etc.)

Re: JScript Panel script discussion/help

Reply #1406
@marc2k3 Following up from the External Tags post I decided to rework on the whole loading images from a radio station into memory

I've reached till this part

Code: [Select]
function on_download_image_done(url, image) {
if (!image) return;
// Do something here to update cover art
}

but I'm not sure how to call on_paint(gr) inside of on_download_image_done assuming that's the function responsible for updating the cover art? or how do I update the Album Art sample with a downloaded image?

Re: JScript Panel script discussion/help

Reply #1407
@marck2k3

Related questions.

Album Art shows the Artist picture just fine playing a normal non streaming file probably using part this part of Preferences - Display - Artist:
C:\Users\User\AppData\Roaming\foobar2000-v2\yttm\art_img\$substr(%artist%,1,1)\%artist%\*.*

While streaming however the artist image is not retrieved/displayed, instead it displays the stub image.

When the artist changes in a stream the following code does update the cover and also changes the textdisplay just fine, but does not do the artist pic.

function on_metadb_changed(handles, fromhook) {
   if (!fromhook) {
      albumart.metadb_changed();
   }
   text.metadb_changed();
}

Can the script be changed so that it retrieves/displays the artist pic as well on realtime stream/artist change?

I like to display the streaming cover as well in my own code.
What is the realtime streaming tag that contains the url to the cover art? I can't find it in your Properties + Other Info.txt or in the standard Item properties which both only show the non-realtime tags?

Re: JScript Panel script discussion/help

Reply #1408
@marc2k3 Following up from the External Tags post I decided to rework on the whole loading images from a radio station into memory

I've reached till this part

Code: [Select]
function on_download_image_done(url, image) {
if (!image) return;
// Do something here to update cover art
}

but I'm not sure how to call on_paint(gr) inside of on_download_image_done assuming that's the function responsible for updating the cover art? or how do I update the Album Art sample with a downloaded image?

Okay I guess this a bad approach, loading images in memory starts to break viewing the image using ShowAlbumArtViewer. Basically I need to manually patch up the image for my playlist and album panel and it would be much better to just download the image file and let m-TAGS/External Tags do the job of attaching the front cover art

Re: JScript Panel script discussion/help

Reply #1409
If those components support attaching images via the normal properties dialog or tagging context menu, it should be transparent to 3rd party components using the same SDK methods. This can attach images but they have to be on disk so you'd have to save with utils.DownloadFileAsync first.

https://jscript-panel.github.io/docs/namespaces/utils/#utilsdownloadfileasyncwindow_id-url-path

https://jscript-panel.github.io/docs/interfaces/IMetadbHandleList/#attachimageimage_path-art_id

Re: JScript Panel script discussion/help

Reply #1410
If those components support attaching images via the normal properties dialog or tagging context menu, it should be transparent to 3rd party components using the same SDK methods. This can attach images but they have to be on disk so you'd have to save with utils.DownloadFileAsync first.

https://jscript-panel.github.io/docs/namespaces/utils/#utilsdownloadfileasyncwindow_id-url-path

https://jscript-panel.github.io/docs/interfaces/IMetadbHandleList/#attachimageimage_path-art_id

That's currently how I was originally using but was under the assumption that downloading it in through the memory would be a much better approach until I tried it... so far utils.DownloadFileAsync does the job.


Re: JScript Panel script discussion/help

Reply #1412
Hey,
I can not get the spectrum seekbar to work. I can seek and click on it but it does not show the spectrum of the song.
Can someone help me to get this to work? :)

I assume it has something to do with ffmpeg but I have no idea how to install this too.

Thanks for any help ♥





 

Re: JScript Panel script discussion/help

Reply #1416
Yes you might say that.  Check here for the whole deal:
https://jscript-panel.github.io/gallery/spectrogram-seekbar/
ah amazing, I did not see it when I was getting Jscrip. Gonna check it out :)  Thanks! ♥

marc2k3's spectrogram doesn't need SoX, it goes right to ffmpeg.  FAST.  You can tell it to generate a lossless png for the image by adding an extension in the "FFmpeg showspectrumpic options" like in the screenshot.  If you would prefer that the image cache be cleared automatically upon Foobar close, add these lines supplied by him to the very end of the "configure" script:
Code: [Select]
function on_script_unload() {
utils.ListFiles(spectrogram_cache).toArray().forEach(function (item) {
utils.RemovePath(item);
});
}

Re: JScript Panel script discussion/help

Reply #1417
Changed the front cover in a FLAC file. However, the old cover is still displayed in the Smooth playlist. How do I get the playlist to re-read the title?
Thank you!

Re: JScript Panel script discussion/help

Reply #1418
The solution is not very elegant. Close fb2k and browse your profile folder.

You can either delete the entire js_smooth_cache folder and this means all thumbnails will be generated again from scratch.

OR

Browse inside the folder and enable the extra large icons view in Explorer. Find and delete the offending files manually.

Re: JScript Panel script discussion/help

Reply #1419
Hi,

I created some keyboard shortcuts 1) Randomize current selection 2) Queue (selected) files 3) Kill the queue. Works fine.

However I would this functionality in buttons.

The randomize button I created works fine with fb.RunMainMenuCommand('Edit/Selection/Sort/Randomize');

The queue button does not work. There is no main menu command to queue so I tried fb.RunContextCommand('Add to playback queue'); but this only adds a track within the selected tracks to the queue if it is playing.

How can I change this code so that all files in the selection are added to the queue?

Re: JScript Panel script discussion/help

Reply #1420
Hi,

I created some keyboard shortcuts 1) Randomize current selection 2) Queue (selected) files 3) Kill the queue. Works fine.

However I would this functionality in buttons.

The randomize button I created works fine with fb.RunMainMenuCommand('Edit/Selection/Sort/Randomize');

The queue button does not work. There is no main menu command to queue so I tried fb.RunContextCommand('Add to playback queue'); but this only adds a track within the selected tracks to the queue if it is playing.

How can I change this code so that all files in the selection are added to the queue?

I just use this for my queue button.
Code: [Select]
	this.buttons.queue = new _button(x + (bs * 5), y, bs, bs, { char : '\ue109', colour: colours.white}, null, function () {		
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
}
}, 'Add to playback queue');

Re: JScript Panel script discussion/help

Reply #1421
I just use this for my queue button.
Code: [Select]
	this.buttons.queue = new _button(x + (bs * 5), y, bs, bs, { char : '\ue109', colour: colours.white}, null, function () {		
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
}
}, 'Add to playback queue');

Thank you! Works very well.

I added rightmouse functionality for the button to remove queued items from selection but that is not really straightforward. If there is one item in the selection that is not queued the command will fail therefore I first had to add it to the queue before removing it.

Code: [Select]
	if (buttons.buttons.queue.containsXY(x, y)) {
var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
handleList.RunContextCommand("Remove from playback queue");
}
return true;
}

In the end I want to add rightmouse functionality to the Randomize selection button, so that it starts playing the first track of the selection after randomizing that selection. I would prefer to set focus to the first element of the selection after randomizing that selection and start playing that element, but I don't know how to set the focus to the first element of the selection.

I tried plman.SetPlaylistFocusItem(plman.ActivePlaylist, 0) but that sets the focus to the first element of the whole playlist.
What variable should be used instead of the 0 to set focus to the first item of the selection?
Also I do not know how to issue a play command that starts playing the focused item. fb.Play() just starts playing the song that is already playing or where playback stopped last time.

So now I use a rather stupid workaround. First I make a handlelist for the whole playlist. Then I add all items to the queue and delete all items (to clear the queue. Is there a better way?). Then I create a handlelist for current selection and add all items to the queue. And finally I issue a fb.Next() command to start playing the first (queued) item), which is the first rack of the selection after it was randomized.

Code: [Select]
		var handleList = plman.GetPlaylistItems(plman.ActivePlaylist)
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
handleList.RunContextCommand("Remove from playback queue");
}

fb.RunMainMenuCommand('Edit/Selection/Sort/Randomize');

var handleList = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
if (handleList && handleList.Count !== 0) {
handleList.RunContextCommand("Add to playback queue");
}

fb.Next();

It works and solves the ordering issue I encountered by creating functionality for on-the-fly "compilation" folders, but I wonder if there's not a better way to it.

Re: JScript Panel script discussion/help

Reply #1422
Not really sure what you're doing but this removes all queue items.

Code: [Select]
fb.RunMainMenuCommand("Playback/Flush playback queue");

If you want to randomise handles for adding to the queue, you don't have to modify any playlist

Code: [Select]
var items = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
items.Randomise();
items.RunContextCommand("Add to playback queue");

Randomise and other handle list methods are documented here...

https://jscript-panel.github.io/docs/interfaces/IMetadbHandleList/

If you want to find the first selected item in a playlist.

Code: [Select]
function first_selected_item(playlistIndex) {
var count = plman.GetPlaylistItemCount(playlistIndex);
for (var i = 0; i < count; i++) {
if (plman.IsPlaylistItemSelected(playlistIndex, i)) {
return i;
}
}
return -1;
}

Always check the return value is not -1.


Re: JScript Panel script discussion/help

Reply #1423
Code: [Select]
fb.RunMainMenuCommand("Playback/Flush playback queue");
Right! Make note to self not to use a space before and after the slash.

I use the code you sent, got it working and ended up with:
Code: [Select]
fb.RunMainMenuCommand("Playback/Flush playback queue");
fb.RunMainMenuCommand("Edit/Selection/Sort/Randomize") // Randomizes selection and displays selection in new order

var items = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
// items.Randomise(); // Randomizes selection but does not display selection in new order
items.RunContextCommand("Add to playback queue");

fb.Next();

I also managed to find and select the first item in the (randomised) selection
Code: [Select]
var sel_first = first_selected_item(plman.ActivePlaylist);
if ( sel_first > -1 ) {
plman.SetPlaylistFocusItem(plman.ActivePlaylist, sel_first);
}

I actually don't want to queue anything. So ideally I would just like to randomize the selection by using the Edit/Selection/Sort/Randomize command which also changes the order in the display like I want it. Then change the focus to the first item in the selection. And then play that item.
When I issue fb.Play however it just restarts the currently playing track and when I issue fb.Next foobar plays the next item below the currently playing file.

Is there a play command available to start playing the focused item?

Re: JScript Panel script discussion/help

Reply #1424
I created rightclick functionality to my Add to queue button. It is supposed to clear any queued item from the current selection.

Code: [Select]
var items = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
items.RunContextCommand("Add to playback queue");
items.RunContextCommand("Remove from playback queue");

Works fine, but a bit weird first have to add all selected items to the queue, but otherwise the Remove command won't work for any of the items in the selection.
(Not any different from the context menu for Remove not being available if one of the items in the selection is not queued).

I read your documentation. In last post you pointed out plman.IsPlaylistItemSelected(playlistIndex, i).

Is there a similar plman.IsPlaylistItemQueued(playlistIndex, i) ?