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: foo_uie_webview (Read 77411 times) previous topic - next topic
0 Members and 9 Guests are viewing this topic.

Re: foo_uie_webview

Reply #575
yup yup, i learnt to right-click along the edges away from images to get the menu.

Re: foo_uie_webview

Reply #576
foo_uie_webview v0.3.0.0-alpha1

* New:
  * Included foobar2000.js wraps the API to make JavaScript development easier. (alpha1)
  * Set permissions in the Preferences dialog. (alpha1)

  * Properties
    * isLibraryEnabled: Returns true if the Media Library is enabled. (alpha1)
    * canReadFiles: Returns true if the component can read local files. (alpha1)
    * canReadDirectories: Returns true if the component can read local directories. (alpha1)
    * canExecuteShellOperations: Returns true if the component can execute shell operations. (alpha1)
 
  * Methods
    * execute(filePath, arguments, directoryPath, operation, showMode): Execites a shell operation on a file. Mostly used to run applications. Check the [SHELLEXECUTEINFOW](https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfow) documentation for the possible values of the parameters. (alpha1)

    * showLibraryPreferences(): Shows the Media Library preferences dialog. (alpha1)
    * searchLibrary(query): Searches the Media Library for matching tracks. Returns a metadb handle list. (alpha1)

    * getMetaDBHandleListCount(list): Returns the number of items in a list of metadb handles. (alpha1)
    * getMetaDBHandleListItem(list, index): Returns the item at the specified index in a list of metadb handles. (alpha1)
    * releaseMetaDBHandleList(list): Releases a list of metadb handles. (alpha1)

    * getMetaDBHandlePath(handle): Gets the path of the specified metadb handle. (alpha1)
    * getMetaDBHandleRelativePath(handle): Gets the path of the specified metadb handle relative to the Media Library folder it is in. (alpha1)
    * getMetaDBHandleLength(handle): Gets the length of the specified metadb handle (in ms). (alpha1)

  * Callbacks
    * onLibraryItemsAdded(items): Called when items have been added to the Media Library. (alpha1)
    * onLibraryItemsModified(items): Called when Media Library items have been modified. (alpha1)
    * onLibraryItemsRemoved(items): Called when Media Library items have been removed. (alpha1)

You can only download it from GitHub during testing.

* The included Default-LibraryTemplate.html file contains example code for the new features.
* As always, the API is far from stable. I'm still experimenting with patterns. Any constructive criticism is appreciated.
* BREAKING CHANGE: This release introduces permissions. The corresponding permission for reading files, reading directories and executing files needs to be enabled first in the Preferences dialog.

Re: foo_uie_webview

Reply #577
About the wrapper:

- Line 36:
Code: [Select]
        chrome.webview.hostObjects.foo_uie_webview.execute(filePath, parameters, directoryPath, operation, showMode);
Should be (missing .sync.):
Code: [Select]
        chrome.webview.hostObjects.sync.foo_uie_webview.execute(filePath, parameters, directoryPath, operation, showMode);
- Same error at line 74 and 84
- Class MediaLibrary, I would say this method should be getter (unless I misunderstood something, it returns directly a property and is not a method: isEnabled
- Class Foobar2000, should be getters: canReadFiles, canReadDirectories, canExecuteShellOperations
- As commented by PM, the MetaDBHandleList constructor may need additional things if you plan to add methods to remove/add handles to it. In any case, the count could be internally cached. Since it's fixed at creation and only changes whenever you add/remove items (which can only happen under user request by specific code).
- MetaDBHandleList: I think at release method you should also delete the actual pointers in the object, otherwise the object itself will be pointing to another undefined object. As result doing things like:
Code: [Select]
const handleList = MetaDBHandleList(...);
handleList.release();
handleList.count;  // 50 but it's not true xd It should either throw or report 0
Will probably either crash your component unless you check all the inputs to be valid (not sure if you are already doing that), crash the JS logic or simply behave wrong. After .release(), this.Source points to a non existent entity, with no indexes. All the properties of the parent should be deleted or set to safe values.
Code: [Select]
    this.release = function () // Using any method or getter will return safe values and do nothing
    {
        const n = this.count;
        for (let i = 0; i < n; ++i) {delete this[i];}
        this.count = 0; // Choosing this instead of void to not invalidate the iterator
        this.release = () => void(0);
        WebView.releaseMetaDBHandleList(this.Source);
        this.Source = void(0);
    };
or just
Code: [Select]
    this.release = function () // Using anything will either throw or return undefined
    {
        WebView.releaseMetaDBHandleList(this.Source);
        Object.keys(this).forEach((key) => delete this.key);
    };
- Let me know if you want me to create a pull request to wrap the methods to create handleList and all that directly from WebView as discussed by PM.
- And just a note about the JSdoc comments, if they are supposed to work in VScode, using  Object.defineProperty for methods/getters and adding comments above will not make them work on intellisense. You have to "reference" them first (I have tried many other supposed workarounds with @name, etc. but they don't work for me at least). Check the images:
Code: [Select]
    /**
        Gets the path.
        @type {string}
    **/
    this.path; // It doesn't mind whether it's set as undefined or just accessed.
    Object.defineProperty(this, 'path',
    {
        get() { return WebView.getMetaDBHandlePath(this.Source); }
    });
- I would also recommend this at the wrapper, which simplifies usage a lot:
Code: [Select]
const WebView = chrome.webview.hostObjects.sync.foo_uie_webview;

Re: foo_uie_webview

Reply #578
foo_uie_webview v0.3.0.0-alpha1
Noticed that if user has not enabled reading directories, but script still attempts to we get a "Class not registered" error. Is there a more descriptive error that can be returned here?

Also, I noticed that onPlaylistItemsReordered returns just a list of numbers for the items parameter (one number for each item in the playlist) and that they are always just numbers in order: [0, 1, ..., n-1, n]. Ignoring the fact that a list of numbers isn't all that helpful, I'm guessing the plan will be things like this return a list of handles?


Re: foo_uie_webview

Reply #580
    * execute(filePath, arguments, directoryPath, operation, showMode): Execites a shell operation on a file.
LOL. Should be "Executes". Lessons Learned: Never let CoPilot write your comments without double checking...

Re: foo_uie_webview

Reply #581
Thx. for the feedback,

About the wrapper:

- Line 36:
Code: [Select]
        chrome.webview.hostObjects.foo_uie_webview.execute(filePath, parameters, directoryPath, operation, showMode);
Should be (missing .sync.):
Code: [Select]
        chrome.webview.hostObjects.sync.foo_uie_webview.execute(filePath, parameters, directoryPath, operation, showMode);
- Same error at line 74 and 84
Those are not errors but intentional. await execute() achieves the same thing. If I hardcode .sync. into the call the developer can only run the code synchronously.

All WebView2 host object methods can be either synchronous or asynchronous by adding or omitting ".sync.".

- Class MediaLibrary, I would say this method should be getter (unless I misunderstood something, it returns directly a property and is not a method: isEnabled
The idea is to emulate static classes. There is only 1 media library and only 1 object of the class should always just 'exist'. I'm still wrestling with the JavaScript syntax (just about as readable as APL or RPG), especially since I haven't figured out how to debug the code.

- Class Foobar2000, should be getters: canReadFiles, canReadDirectories, canExecuteShellOperations
Agreed, once I figure out the JavaScript syntax.

- As commented by PM, the MetaDBHandleList constructor may need additional things if you plan to add methods to remove/add handles to it. In any case, the count could be internally cached. Since it's fixed at creation and only changes whenever you add/remove items (which can only happen under user request by specific code).
At this point I don't see a scenario *yet* in which JavaScript 'creates' a MetaDBHandleList. It is a wrapper around an unmanaged resource. The lifespan is currently determined by the component.

- MetaDBHandleList: I think at release method you should also delete the actual pointers in the object, otherwise the object itself will be pointing to another undefined object. As result doing things like:
Code: [Select]
const handleList = MetaDBHandleList(...);
handleList.release();
handleList.count;  // 50 but it's not true xd It should either throw or report 0
Will probably either crash your component unless you check all the inputs to be valid (not sure if you are already doing that), crash the JS logic or simply behave wrong. After .release(), this.Source points to a non existent entity, with no indexes. All the properties of the parent should be deleted or set to safe values.
True. Still figuring out the best way to wrap things in JavaScript.

Code: [Select]
    this.release = function () // Using any method or getter will return safe values and do nothing
    {
        const n = this.count;
        for (let i = 0; i < n; ++i) {delete this[i];}
        this.count = 0; // Choosing this instead of void to not invalidate the iterator
        this.release = () => void(0);
        WebView.releaseMetaDBHandleList(this.Source);
        this.Source = void(0);
    };
or just
Code: [Select]
    this.release = function () // Using anything will either throw or return undefined
    {
        WebView.releaseMetaDBHandleList(this.Source);
        Object.keys(this).forEach((key) => delete this.key);
    };
That will not work: the handles in the handle list are owned by fb2k. Releasing the list destroys all its items. You're not supposed to be release the 'item' handles yourself.

Re: foo_uie_webview

Reply #582
foo_uie_webview v0.3.0.0-alpha1
Also, I noticed that onPlaylistItemsReordered returns just a list of numbers for the items parameter (one number for each item in the playlist) and that they are always just numbers in order: [0, 1, ..., n-1, n]. Ignoring the fact that a list of numbers isn't all that helpful, I'm guessing the plan will be things like this return a list of handles?
I currently expose the fb2k API as 'raw' as it gets. This is what API gives me. I can sugarcoat this in C++ but then every developer gets the extra added weight. Don't you think it's better to add the sugarcoating in the new 'foobar2000.js'?

Re: foo_uie_webview

Reply #583
foo_uie_webview v0.3.0.0-alpha1
Noticed that if user has not enabled reading directories, but script still attempts to we get a "Class not registered" error. Is there a more descriptive error that can be returned here?
JavaScript is so weird... The error returned is E_ACCESSDENIED which should be translated more accurately in JS, IMHO.

I haven't really looked into the whole error reporting business. What's the most suitable/used pattern used in JavaScript knowing I can't raise JS exceptions from the C++ code?

Re: foo_uie_webview

Reply #584
Quote
All WebView2 host object methods can be either synchronous or asynchronous by adding or omitting ".sync.".
I see, thought it was an error. That kind of nesting makes things a bit more difficult, since there are 2 webView namespaces.
Code: [Select]
chrome.webview.hostObjects.foo_uie_webview

Code: [Select]
chrome.webview.hostObjects.sync.foo_uie_webview

No idea how are you doing it, but obviously it would be much more simple if sync/async methods are just called using flags or different names within the same namespace.

Quote
At this point I don't see a scenario *yet* in which JavaScript 'creates' a MetaDBHandleList. It is a wrapper around an unmanaged resource. The lifespan is currently determined by the component.
For ex. at some point you may want to merge 2 handle lists or add tracks by some queries to a handle list and then send it to a playlist (instead of sending every track to a playlist which would be much slower).

Quote
That will not work: the handles in the handle list are owned by fb2k. Releasing the list destroys all its items. You're not supposed to be release the 'item' handles yourself.
I'm not saying that releases the handles. You have .releaseMetaDBHandleList() for that. Obviously. But you still have a JS wrapper object there, you have to do something with it to avoid situations like the one above. Release method takes care of the actual handles, but if you are wrapping it, you also have to clean the wrapper and make sure its methods don't work anymore, throw or output safe values.

Quote
I haven't really looked into the whole error reporting business. What's the most suitable/used pattern used in JavaScript knowing I can't raise JS exceptions from the C++ code?
In SMP the error throws a message, the line of code and callstack that lead to that line of code. Except for really complex code, it usually gives you pretty clear clues about what's going wrong.

Re: foo_uie_webview

Reply #585
Quote
All WebView2 host object methods can be either synchronous or asynchronous by adding or omitting ".sync.".
I see, thought it was an error. That kind of nesting makes things a bit more difficult, since there are 2 webView namespaces.
Code: [Select]
chrome.webview.hostObjects.foo_uie_webview

Code: [Select]
chrome.webview.hostObjects.sync.foo_uie_webview

No idea how are you doing it, but obviously it would be much more simple if sync/async methods are just called using flags or different names within the same namespace.
Not my choice. Imposed by the WebView2 API.

Quote
At this point I don't see a scenario *yet* in which JavaScript 'creates' a MetaDBHandleList. It is a wrapper around an unmanaged resource. The lifespan is currently determined by the component.
For ex. at some point you may want to merge 2 handle lists or add tracks by some queries to a handle list and then send it to a playlist (instead of sending every track to a playlist which would be much slower).
True. We'll cross that bridge when we get there.

Release method takes care of the actual handles, but if you are wrapping it, you also have to clean the wrapper and make sure its methods don't work anymore, throw or output safe values.
True. I wanted to get a first taster out after researching for a while. The wrapper can and will be made safer and more stable.

Quote
I haven't really looked into the whole error reporting business. What's the most suitable/used pattern used in JavaScript knowing I can't raise JS exceptions from the C++ code?
In SMP the error throws a message, the line of code and callstack that lead to that line of code. Except for really complex code, it usually gives you pretty clear clues about what's going wrong.
Did I mention I can't throw exceptions?

I'm getting the impression that the whole host object API in WebView2 seems like an afterthought and is treated as non-essential. I can hardly find any recent discussion about it.

Re: foo_uie_webview

Reply #586
In JS you have this.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error

At least the message part can be provided. Not sure if the stack trace part works in WebView2.
You could send all errors to JS as JSON and then throw there with the native JS methods (again the JS wrapper would be needed).

Re: foo_uie_webview

Reply #587
Also, I noticed that onPlaylistItemsReordered returns just a list of numbers for the items parameter (one number for each item in the playlist) and that they are always just numbers in order: [0, 1, ..., n-1, n]. Ignoring the fact that a list of numbers isn't all that helpful, I'm guessing the plan will be things like this return a list of handles?
I currently expose the fb2k API as 'raw' as it gets. This is what API gives me. I can sugarcoat this in C++ but then every developer gets the extra added weight. Don't you think it's better to add the sugarcoating in the new 'foobar2000.js'?
I do think for some things (possibly the Error responses?) foobar2000.js is the way to go.

This one is weird, because it's always just numbers in order, one for each item in the playlist. The order of the numbers never changes even when you reorder songs.... it just is always the same 0 to N. If there's no plan to ever have it return handles, then it probably shouldn't return anything because the numbers don't actually mean anything.

Re: foo_uie_webview

Reply #588
Also, I noticed that onPlaylistItemsReordered returns just a list of numbers for the items parameter (one number for each item in the playlist) and that they are always just numbers in order: [0, 1, ..., n-1, n]. Ignoring the fact that a list of numbers isn't all that helpful, I'm guessing the plan will be things like this return a list of handles?
I currently expose the fb2k API as 'raw' as it gets. This is what API gives me. I can sugarcoat this in C++ but then every developer gets the extra added weight. Don't you think it's better to add the sugarcoating in the new 'foobar2000.js'?
I do think for some things (possibly the Error responses?) foobar2000.js is the way to go.

This one is weird, because it's always just numbers in order, one for each item in the playlist. The order of the numbers never changes even when you reorder songs.... it just is always the same 0 to N. If there's no plan to ever have it return handles, then it probably shouldn't return anything because the numbers don't actually mean anything.
The numbers do mean something: they are the indexes in the original playlist but in a new sequence. The callback is actually a misnomer: your code gets called 'after' the reordering has happened but 'before' the playlist has been updated on the screen. onPlaylistReordering() would be better.

Re: foo_uie_webview

Reply #589
The numbers do mean something: they are the indexes in the original playlist but in a new sequence. The callback is actually a misnomer: your code gets called 'after' the reordering has happened but 'before' the playlist has been updated on the screen. onPlaylistReordering() would be better.
Sorry, I double checked and yes the numbers do get reordered. Didn't seem like they were at first. Ignore me :D

Re: foo_uie_webview

Reply #590
foo_uie_webview v0.3.0.0-alpha2, Happy New Year

* New:
  * Methods
    * showSearchUI(filter): Shows the library search UI initialized with the specified filter.
    * formatMetaDBHandleTitle(handle, text): Formats the title of the specified metadb handle with the specified title formatting text.
    * sortMetaDBHandleListByFormat(format): Sorts a list of metadb handles by the specified title format.
    * sortMetaDBHandleListByPath(): Sorts a list of metadb handles by the path.
    * sortMetaDBHandleListByRelativePath(): Sorts a list of metadb handles by the relative path.
    * removeMetaDBHandleListDuplicates(): Removes duplicate items from a metadb handle list.
    * calculateMetaDBHandleListDuration(): Calculates the total duration of a list of metadb handles.
    * cloneMetaDBHandleList(): Clones a list of metadb handles.
    * clearMetaDBHandleList(): Clears a list of metadb handles.
    * addMetaDBHandleList(): Adds the items of a metadb handle list to another.
  * Properties
    * lastErrorNumber: Gets the number of the last error.
    * lastErrorMessage: Gets the message of the last error.
* Changed: canReadFiles, canReadDirectories, canExecuteShellOperations and isEnabled are properties now.
* Improved: Expanded JSDoc comments in foobar2000.js.
* Improved: Expanded error checking and handling in foobar2000.js.

You can only download it from GitHub during testing.

* Experimental: foobar2000,js contains a new Foobar2000Error class. readAllText(), readDirectory() and execute() will throw this exception when they fail. Please let me know if this pattern works to improve error handling in JavaScript.

Re: foo_uie_webview

Reply #591
WebView 0.2.1.0 not working (empty field). Foobar2000 1.6.18.

Re: foo_uie_webview

Reply #592
Reply #514: https://hydrogenaud.io/index.php/topic,126042.msg1055683.html#msg1055683
Is this it?

It's easier to create a new Panel.
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD620S, SENNHEISER HD 490 Pro Plus, beyerdynamic DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH1000XM5 (made a Upgrade/Balanced Cable by myself)


 

Re: foo_uie_webview

Reply #594
WebView
Current version: 0.2.1.0, released on 2024-12-15
https://www.foobar2000.org/components/view/foo_uie_webview

foobar2000 v1.6.18
I use it without any problems.



foo_uie_webview - GitHub
https://github.com/stuerp/foo_uie_webview/releases/
@chamuco Excuse me, where is it written?
---------
foo_uie_webview - Home
https://github.com/stuerp/foo_uie_webview

Requirements
> foobar2000 v2.0 or later (32 or 64-bit)

Oh, when did that happen?
Isn't it from v0.3.0.0-alpha?
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD620S, SENNHEISER HD 490 Pro Plus, beyerdynamic DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH1000XM5 (made a Upgrade/Balanced Cable by myself)

Re: foo_uie_webview

Reply #595
Requirements
> foobar2000 v2.0 or later (32 or 64-bit)

Oh, when did that happen?
Isn't it from v0.3.0.0-alpha?
From the beginning. It just means that I don't test with 1.6 anymore. Your mileage may vary, especially when I start exposing newer API's to JavaScript.

Re: foo_uie_webview

Reply #596
> From the beginning.
What? orz
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD620S, SENNHEISER HD 490 Pro Plus, beyerdynamic DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH1000XM5 (made a Upgrade/Balanced Cable by myself)

Re: foo_uie_webview

Reply #597
Foobar2000-x64_v2.24.1 WebView 0.2.1.0 also not working (empty field with inscription "WebView")!

Re: foo_uie_webview

Reply #598
Do you open Explorer and specify the *.html file?
e.g. \profile\foo_uie_webview\xxxx\xxx.html
SHURE SRH1840, SENNHEISER HD660S2, SENNHEISER HD620S, SENNHEISER HD 490 Pro Plus, beyerdynamic DT 1990 PRO, HiFiMAN Edition XS, Bowers & Wilkins P7, FiiO FT5, 水月雨 (MOONDROP) 空鳴 - VOID, Nakamichi Elite FIVE ANC, SONY WH1000XM5 (made a Upgrade/Balanced Cable by myself)

Re: foo_uie_webview

Reply #599
But it is normal that the minimum volume I see in the foobar2000 bar reaches -55.60 then jumps to -66.50 and goes on mute.

I'm asking because I'm having synchronization problems between the volume up and volume down function in the audio container which will replace the custom track and progressively all the JS3 modules: