Help - Search - Members - Calendar
Full Version: How to get the song rating
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
eyebex
I've overridden play_callback::on_playback_edited() assuming this will get called when the song rating was changed using foobar. Now, how am I supposed to get the new rating from the metadb_handle_ptr argument?

Thanks.
eyebex
This is what I came up with:

CODE
void on_playback_edited(metadb_handle_ptr p_track) {
    file_info_impl info;
    if (p_track->get_info(info)) {
        int rating=atoi(get_rating(info));
        SendMessage(m_cda_window,WM_USER,static_cast<WPARAM>(rating),IPC_RATING_CHANGED_NOTIFICATION);
    }
}


CODE
static char const* get_rating(file_info_impl const& info) {
    char const* rating=info.meta_get("RATING",0);
    if (!rating) {
        rating=info.meta_get("TRACKRATING",0);
    }
    if (!rating) {
        rating=info.meta_get("ALBUMRATING",0);
    }
    return rating;
}
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.