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: a few simple questions (Read 5170 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

a few simple questions

hi,
i have been using columns ui for a long time. now i wanted to add a podcatcher but sadly foo_podcatcher does not support columns ui panels. therefore i set out to create my own little columns ui-podcatcher. i have it more or less up and running now, but there are a few questions that maybe someone here can answer. the most annoying thing with columns ui is obviously that it's not compatible with the latest foobar sdk (at least i failed to get it to work :/) hopefully it gets an update soon. anyway my (newbie) questions are the following:

- foobar2000 likes to manage config-files for components. that's ok with me, but in some situations its a lot more practical to create ones own file. foo_podcatcher for example creates a sqlite-db named foo_podcatcher.dll.db in the configuration folder. i would like to do the same: is there some interface-function that returns the path to the configuration-folder? if not: can i somehow determine if it's a normal or portable foobar installation?

- when i create a playlist from a podcast-feed i atm use hint_async to set information about items and it works fine. i am just not really sure what a hint is, when it should be used and when foobar uses it ? =) btw: how can i set the "Length" of a track with a hint?

- if i use the old, simple preferences_page_v2 (i am not using atl) for a preference dialog, can i still support the "ok/cancel/apply"-buttons? and if yes how? i know this is pretty old, but i am using https://github.com/msquared2/columns_ui as a basis atm and that has a very old sdk. if someone has something newer that works i would be very very thankful

thanks alot!

a few simple questions

Reply #1
is there some interface-function that returns the path to the configuration-folder? if not: can i somehow determine if it's a normal or portable foobar installation?

foobar2000\SDK\core_api.h:
Code: [Select]
namespace core_api {
    const char * get_profile_path();
    bool is_portable_mode_enabled();
};

a few simple questions

Reply #2
is there some interface-function that returns the path to the configuration-folder? if not: can i somehow determine if it's a normal or portable foobar installation?

foobar2000\SDK\core_api.h:
Code: [Select]
namespace core_api {
    const char * get_profile_path();
    bool is_portable_mode_enabled();
};


wow that was simple =) thx

a few simple questions

Reply #3
- if i use the old, simple preferences_page_v2 (i am not using atl) for a preference dialog, can i still support the "ok/cancel/apply"-buttons? and if yes how? i know this is pretty old, but i am using https://github.com/msquared2/columns_ui as a basis atm and that has a very old sdk. if someone has something newer that works i would be very very thankful


the new preferences dialog needs at least the v1 SDK. looking at the SDK download page, v1.1 (2011-03-11) is still available and i'm pretty sure i was able to make columns UI and that SDK compile with minimum fuss. compiling really is the limit of my capabilities though. i can't help with how to implement... anything.

a few simple questions

Reply #4
the new preferences dialog needs at least the v1 SDK. looking at the SDK download page, v1.1 (2011-03-11) is still available and i'm pretty sure i was able to make columns UI and that SDK compile with minimum fuss. compiling really is the limit of my capabilities though. i can't help with how to implement... anything.


thanks, i will have a look at it. (btw: i am amazed how fast you guys answered: i half expected this forum to be kind of dead ^^)

a few simple questions

Reply #5
the new preferences dialog needs at least the v1 SDK. looking at the SDK download page, v1.1 (2011-03-11) is still available and i'm pretty sure i was able to make columns UI and that SDK compile with minimum fuss. compiling really is the limit of my capabilities though. i can't help with how to implement... anything.

thanks, i will have a look at it. (btw: i am amazed how fast you guys answered: i half expected this forum to be kind of dead ^^)

you are right it works (with a little modification of the columns-ui-sdk-source at least). preferences_page_v3 here i come . but to be honest i have no idea how i should implement
Code: [Select]
preferences_page_instance::ptr instantiate(HWND parent, preferences_page_callback::ptr callback)
without the atl helper templates. but i hate atl, that is: i don't want all these additional dependencies & possible linker chaos for my little preferences dialog. help, anyone ? ^^

a few simple questions

Reply #6
i am now pretty sure that column ui *should* work with the latest sdk. but i am apparently too stupid to compile it (and too tired after 2 hours of messing about)

one golden guinea for anyone who resolves the 9 unsolved links in this example ("MT Debug") ^^
foo_uie_template_newsdk.zip

a few simple questions

Reply #7
ok i added so many stupid questions/posts to this thread that i fear nobody will read it anymore. but i don't want to create yet another thread, so here i try again:

i have the following situation: a thread has downloaded a file and now i want to add it to a playlist (in the background). he calls some threadsafe callback-function.

the problem: nearly all metadb methods can only be called from the main thread (and process_location() etc. create this annoying "progress"-window). how can i read the tag-information of a file (that is not even in the database yet!) from inside a helper-thread? of course i could use another tag-library like taglib and then hint_async, but this seems kind of silly when writing a plugin for a program that clearly has all this functionality. anyway there is probably a very simple solution to this?


a few simple questions

Reply #8
- when i create a playlist from a podcast-feed i atm use hint_async to set information about items and it works fine. i am just not really sure what a hint is, when it should be used and when foobar uses it ? =) btw: how can i set the "Length" of a track with a hint?
foobar2000 caches metadata about tracks (not files!) for faster access. The cached metadata includes the file size, the file modification time, the duration of the track, used-defined tags and technical information (codec, sample rate, bit depth, ...). foobar2000 uses the file size and file modification time to detect when it needs to reload the cached information. When a reference to a new track (a metadb_handle) is created the cache contains no information about the track. Normally foobar2000 would have to access the file to read the information into the cache. The hint function exists to populate the cached information for a track without accessing the file. This is used when reading FPL playlists since they contain a copy of the cached information. Note that you cannot use the hint mechanism to override the cache information. When the user request to reload the information from the track foobar2000 will replace the cached information.

The process_locations or process_locations_async functions are the recommended way to get the metadb_handles for a file (or more generally a list of paths). The handle files with multiple tracks as well as playlist files. These functions also display an "annoying" dialog so the user can cancel the operation if it gets stuck or takes longer than expected.

Nonetheless there are valid cases when you need to read the information directly from the file. See the thread foobar2000 v1.3 upcoming changes for details. It also provides a code snippet showing how to do this. By the way you can get the number of tracks in a file using the input_info_reader::get_subsong_count method.

For the implementation of the preferences_page_v3::instantiate method you need to do the following. Create a child window using the given window handle as the parent window. The most convenient way to do this is to create a non-modal dialog from a dialog template. You should use the WS_CHILD and WS_EX_CONTROLPARENT window styles. Store the callback reference for use in you window procedure. Use it to notify the preferences window when the state of your preferences window changes, i.e. when the enabled state of the apply button needs to be updated. The instantiate method needs to return an implementation of the preferences_page_instance interface. foobar2000 uses this to get the window handle for your preferences page and to query the state of the Apply button.  It also uses it to notify you when you need to save or reset the configuration data, i.e. when the user clicks Apply, OK or one of the Reset buttons. The intention is that the user can edit the value on the preferences page but that the changes do not take effect until the user clicks Apply or OK.

A common pitfall in this scenario is the lifecycle management of your objects. The window procedure and the preferences_page_instance object will need some shared data. You need to keep this shared data alive until both the window and the preferences_page_instance have been destroyed to avoid dangling pointers. Look up the difference between the WM_DESTROY and WM_NCDESTROY window messages if you don't already know it! You should also avoid leaking memory. The WTL based helper classes take care of these subtleties.

a few simple questions

Reply #9
- when i create a playlist from a podcast-feed i atm use hint_async to set information about items and it works fine. i am just not really sure what a hint is, when it should be used and when foobar uses it ? =) btw: how can i set the "Length" of a track with a hint?
foobar2000 caches metadata about tracks (not files!) for faster access. The cached metadata includes the file size, the file modification time, the duration of the track, used-defined tags and technical information (codec, sample rate, bit depth, ...). foobar2000 uses the file size and file modification time to detect when it needs to reload the cached information. When a reference to a new track (a metadb_handle) is created the cache contains no information about the track. Normally foobar2000 would have to access the file to read the information into the cache. The hint function exists to populate the cached information for a track without accessing the file. This is used when reading FPL playlists since they contain a copy of the cached information. Note that you cannot use the hint mechanism to override the cache information. When the user request to reload the information from the track foobar2000 will replace the cached information.

The process_locations or process_locations_async functions are the recommended way to get the metadb_handles for a file (or more generally a list of paths). The handle files with multiple tracks as well as playlist files. These functions also display an "annoying" dialog so the user can cancel the operation if it gets stuck or takes longer than expected.

Nonetheless there are valid cases when you need to read the information directly from the file. See the thread foobar2000 v1.3 upcoming changes for details. It also provides a code snippet showing how to do this. By the way you can get the number of tracks in a file using the input_info_reader::get_subsong_count method.

For the implementation of the preferences_page_v3::instantiate method you need to do the following. Create a child window using the given window handle as the parent window. The most convenient way to do this is to create a non-modal dialog from a dialog template. You should use the WS_CHILD and WS_EX_CONTROLPARENT window styles. Store the callback reference for use in you window procedure. Use it to notify the preferences window when the state of your preferences window changes, i.e. when the enabled state of the apply button needs to be updated. The instantiate method needs to return an implementation of the preferences_page_instance interface. foobar2000 uses this to get the window handle for your preferences page and to query the state of the Apply button.  It also uses it to notify you when you need to save or reset the configuration data, i.e. when the user clicks Apply, OK or one of the Reset buttons. The intention is that the user can edit the value on the preferences page but that the changes do not take effect until the user clicks Apply or OK.

A common pitfall in this scenario is the lifecycle management of your objects. The window procedure and the preferences_page_instance object will need some shared data. You need to keep this shared data alive until both the window and the preferences_page_instance have been destroyed to avoid dangling pointers. Look up the difference between the WM_DESTROY and WM_NCDESTROY window messages if you don't already know it! You should also avoid leaking memory. The WTL based helper classes take care of these subtleties.


Thank you very much for your detailed answers. I wanted to avoid wtl mostly because I have no real experience with it (i am normally a qt (or even wxwidgets) guy), but after having a look at wtl I might use it afterall for the component. By the way: It turns out it is absolutly no problem to use the latest sdk with columns ui (one only needs to update the service_factory_base constructor for ui_extension::window_factory etc). It's embarrassing to admit but i forgot that ms changed the way project dependencies need to be defined [with vs2010 already]...