Skip to main content
Topic: JScript Panel (Read 74016 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

JScript Panel

Reply #50
I'm not really sure why you removed the file. The error tells you exactly what to do:

Quote
"It appears the cached file has been corrupted. Use the right click menu>Force Update to try again."


If it's happening randomly (fixed by a forced update) then there isn't much I can do. If you can't get the bio of specific artist with multiple retries then I can take a look if you tell me what the artist is.

edit: If you reply, please do it in the script thread: https://www.hydrogenaud.io/forums/index.php?showtopic=110516

JScript Panel

Reply #51
    I am in the process of finalising a Jscript "Library  Tree" and have come across a few points. Please can you consider the following  requests.

   
  • Something like fb.GetLibraryPaths -> array of media library\music  folder paths. This will make it easier to generate a view by folder structure  like that in album list, where the common paths aren't shown, rather than the user having to duplicate the paths in  the panel properties.
   
  • Stop on_mouse_leave() being called when the mouse  pointer is over a tooltip. As it is I have an issue with tooltips persisting  when toggle to another program. This is because in my usage scenario I cannot  use on_mouse_leave() to deactivate the tooltip. This is not a problem with  normal button tooltips where the tooltip is usually offset from the mouse  pointer and on_mouse_leave() can then be used to kill the tooltip. But in browser  or playlists tooltips where the mouse pointer is over the tooltip, on_mouse_leave()  cannot be used.
   
  • Enable on_mouse_wheel() to be called when mouse pointer  is over a tooltip. As it is, mouse wheel scrolling is blocked whenever over a  tooltip. Again this is seen in browser & playlist type tooltips. Other  mouse callbacks like on_mouse_lbtn_down() get called while over a tooltip.

JScript Panel

Reply #52
1) From what I can see, nothing like that is available. There is a library get_relative_path for metadb handles so I guess that could be added. You'd then have to loop through all library items and strip it from the full path to get the library folder.

2) I don't see that as a component issue. You can track the mouse yourself, use timers to prevent code running, mess around with SetDelayTime etc. FWIW, I never deactivate tooltips. If I want to clear them, I just set the tooltip text as an empty string and activate it.

3) I'll look in to it but given my zero knowledge/skills, I'm not sure I'll get very far.


JScript Panel

Reply #54
Thanks for adding fb.GetLibraryRelativePath. I look forward to trying it out when a new version is released. 

#2 The problem is when them mouse is over a tooltip with tooltip showing. Then when Alt + Tab to a different program, the tooltip will still show. I thought SetDelayTime() delays the appearance of the tooltip and so I don't see how that helps remove a tooltip when the window is left. I also don't see how mouse tracking (you mean through on_mouse_move?) can be used to report if the window is left, since it doesn't report a change in that scenario. I had already tried these before I originally posted & have unsuccessfullly tried them again. The solution which I was also using before I originally posted is to use a timer, but the tooltip will still show when Alt + Tab to a different window until the timer kicks in.

So it seems the proper way of doing it would be to use on_mouse_leave to kill the tooltip - but that doesn't work when the mouse is over the tooltip as that triggers the callback. I note that in your helpers button example you do use on_mouse_leave (this.leave -> tt("")) to kill the tooltip - here the mouse isn't over the tooltip.

Probably you aren't able to change the on_mouse_leave operation in JScript panel, & since there may be no other workaround, the timer will have to do. Else if I am overlooking something please advise.

JScript Panel

Reply #55
For your alt-tab problem, you should be able to use the on_focus callback.

Code: [Select]
function on_focus(is_focused) {
    if (!is_focused) //clear tooltips
}

JScript Panel

Reply #56
Thanks, it helps. It works if the JScript panel has focus (i.e. last mouse click is in the panel). Then Alt + Tab causes the JScript panel to lose focus. 

But tooltips show even when the panel hasn't focus (e.g. last click in playlist and mouse over JScript panel), and so then its not called on Alt + Tab, because the JScript panel focus doesn't change, and so doesn't work.

JScript Panel

Reply #57
Code: [Select]
v1.0.7
- ADD: fb.GetLibraryRelativePath(handle)


https://github.com/19379/foo-jscript-panel/releases

It should be noted that the SDK function used to get the relative path has a special warning. 

Quote
//! SPECIAL WARNING: to allow multi-CPU optimizations to parse relative track paths, this API works in threads other than the main app thread. Main thread MUST be blocked while working in such scenarios, it's NOT safe to call from worker threads while the Media Library content/configuration might be getting altered.


I had a quick poke around the columns UI album list code and that doesn't appear to be doing anything special except the loop through all library items is inside a try/catch statement so that would be my recommendation as well.

@colagen, I didn't add your UpdateFileInfoArray method because I want to try and get it working with multi-value tags.

JScript Panel

Reply #58
<???> fb.GetLibraryRelativePath(handle)

what does it return ? a string ? an array (i hope so cause library can be set w/ many paths in foobar2000) ? ...

JScript Panel

Reply #59
It's the relative path for a given track. Look at the example in the docs.

If you want to determine the folders set in the preferences, this bit of code should do it. It's crudely stripping out the relative path from the full path to give the base folder. I don't know how else you would do it.

Code: [Select]
var items = fb.GetLibraryItems();
items.OrderByPath();
var current = "";
var folders = [];
for (var i = 0; i < items.Count; i++) {    
    var temp = items.Item(i).Path.replace(fb.GetLibraryRelativePath(items.Item(i)), "");
    if (temp != current) {
        current = temp;
        folders.push(current);
    }
}
fb.ShowPopupMessage(folders.join("\n"));

JScript Panel

Reply #60
  Just to confirm that fb.GetLibraryRelativePath is exactly what was required for my purposes and that it's working extremely well.

 

JScript Panel

Reply #61
ok, thanx for pointing me to the right use

JScript Panel

Reply #62
As I can see, the mouse scroll callback only supports the vertical wheel.
Is it possible to use horizontal scrolling in it?

JScript Panel

Reply #63
A quick google suggests adding a new callback should be trivial. However, I've just got a new SSD with a fresh install of windows and I don't want to clutter it up with Visual Studio so you'll have to wait until I set up a dual boot or virtual machine.

JScript Panel

Reply #64
@Scrummble, can you test this and see if it works (it's the dll only)

edit: link removed. JSplaylist is going mental with it.   

edit2: can you just confirm you're talking about a mouse wheel that tilts left/right? A bit more reading shows that some people are holding down shift while scrolling normally and this is something you can implement yourself.

Code: [Select]
//flags
var VK_SHIFT = 0x10;

function on_mouse_wheel(s) {
    if (utils.IsKeyPressed(VK_SHIFT)) {
        //scroll left/right
    } else {
        //scroll normally
    }
}

Re: JScript Panel

Reply #65
While fb.GetLibraryItems() works extremely well on many queries and is an excellent addition, there are some queries it can’t handle resulting in a crash. So I was wondering if this was something that you were able to fix. Current workaround is to use catch error. Here’s hoping there’s a simple fix... Just putting the below in a panel causes the indicated crashes for me.

plman.GetQueryItems(fb.GetLibraryItems(), "%last_played% DURING LAST 2 WEEKS") // CRASH
plman.GetQueryItems(fb.GetLibraryItems(), "%last_modified% DURING LAST 2 WEEKS") // CRASH
plman.GetQueryItems(fb.GetLibraryItems(), "%artist% HAS beatles") // OK
plman.GetQueryItems(fb.GetLibraryItems(), "artist HAS beatles") // OK
plman.GetQueryItems(fb.GetLibraryItems(), "rating IS 5") // OK


Re: JScript Panel

Reply #66
The C++ I copied from another component also uses a try/catch statement and when I compiled it with the try/catch removed, it crashed hard bringing down foobar with this error in the crash log:

Quote
System time operations not available in this context

I'm guessing it just needs updating to use something newer provided in the SDK.

Re: JScript Panel

Reply #67
Oh noes, I made a breaking change. GetQueryItems should never have been a plman method and I apologise for that. It is now a fb method. For that reason, we are now on v1.1.0

https://github.com/19379/foo-jscript-panel/releases

Code: [Select]
v1.1.0
- CHG: GetQueryItems should be a "fb" method, not "plman".
- FIX: Fix crash when using GetQueryItems with dates as part of the query.
- CHG: Update Columns UI SDK to 6.5

I've added a note to the docs as well.

Code: [Select]
		fb.GetQueryItems(handle_list, query); (IFbMetadbHandleList)
/*
example1: var fav_playlist_items = fb.GetQueryItems(plman.GetPlaylistItems(plman.ActivePlaylist), "rating IS 5");
example2: var fav_library_items = fb.GetQueryItems(fb.GetLibraryItems(), "rating IS 5");
results are unsorted

NOTE: use try/catch to handle invalid queries. An empty handle list will be returned if the query is valid but there are no results.
*/

Re: JScript Panel

Reply #68
In fact I did not get it when you mentioned "shift".
Have you ever seen a mouse with dual wheels? One wheel vertical and one horizontal, that's what I was talking about.
Personally I use a Macbook Air with Win10 on Parallel Desktop, and the touchpad supports horizontal scrolling, which works fine on Microsoft Edge, Chrome, Notepad2, Excel and Word (while ironically File Explorer and PowerPoint does not support this; ELPlaylist on fb2k even has a bug showing a blank area).


Re: JScript Panel

Reply #70
Thanks for the speedy fix. Just to confirm that fb.GetQueryItems() seems to be working correctly now.  :)

Re: JScript Panel

Reply #71
Hi
After I installed 1.1.1 plugin through foobar interface and restarted foobar, I get this error:

Failed to load DLL: foo_jscript_panel.dll
Reason: A dynamic link library (DLL) initialization routine failed. 

what could be the reason? I never used JScript Panel before, this is first time I install it

ye and it shows "(component not loaded)" in component list

foobar 1.3.9


Re: JScript Panel

Reply #73
no, Windows 7 32 'N' version

and foobar without Column UI

Re: JScript Panel

Reply #74
Well I cannot explain that. It should work on any version of windows 7.

 
SimplePortal 1.0.0 RC1 © 2008-2018