Help - Search - Members - Calendar
Full Version: Returning unicode filename, possible?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
Zerox Millienium
I have written some code to get the filename of the resource that is currently playing, however, I realized the encoding of the filename returned will always be in mbcs. Is there a built-in feature in the SDK that would allow the extraction of the unicode filename or fb2000 isn't going to read from unicode file systems, such as on Windows 2k/XP/2003/Vista

If not, I do have to resort to using MultiCharToWideChar() function of the Windows SDK?

CODE

            static_api_ptr_t<playlist_manager> plm;

            bool bSuccess;
            t_size activePlaylistIndex;
            t_size playingItemIndex;
            metadb_handle_ptr playingItemMetadbHandle;

            activePlaylistIndex = plm->get_active_playlist();
            if (activePlaylistIndex != infinite)
            {
                bSuccess = plm->get_playing_item_location(&activePlaylistIndex, &playingItemIndex);
                if (bSuccess)
                {
                    bSuccess = plm->playlist_get_item_handle(playingItemMetadbHandle, activePlaylistIndex, playingItemIndex);
                    if (bSuccess)
                    {
                        const char* filename = playingItemMetadbHandle->get_path();
                        if (filename != NULL && !strncmp(filename, "file://", 7))
                        {
                            console::info((filename + 7));
                        }
                    }
                }
            }
foosion
foobar2000 uses UTF-8 internally, and there are helper functions in the pfc::stringcvt namespace to convert between UTF-8, ANSI, and UTF-16. There are also several UTF-8 wrappers for Win32 functions in shared.dll.

By the way, the easiest way (and the most reliable one, since the playing track does not need to be in a playlist) is as follows:
CODE
metadb_handle_ptr track;
if (static_api_ptr_t<playback_control>()->get_now_playing(track)) { /* do whatever */ }
Zerox Millienium
Thank you very much for your help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.