IPB

Welcome Guest ( Log In | Register )

> foobar2000 Development Forum Rules

This forum is for developer discussions only. If you have a problem / bug report / idea / feature request that isn't related to foobar2000 SDK, post it in an appropiate forum instead - tech support questions go to support forum, everything else goes to general forum.
All non-developer posts on this forum will be removed. Continued abuse of this forum will result in admin actions (warnings, account suspension).

 
Reply to this topicStart new topic
Changing the rating of songs, in playback_statistics, not the TAG of the file
orbbu
post Jul 7 2011, 15:19
Post #1





Group: Members
Posts: 7
Joined: 7-July 11
Member No.: 92106



Hello, this is my first day coding a component for foobar smile.gif

I cant find informations about how to change the rating field of a track. Here is the code I wrote

static_api_ptr_t<playlist_manager> _pm;
t_size _pl = _pm->get_active_playlist();
metadb_handle_list _its;
_pm->playlist_get_selected_items(_pl, _its);
if(_its.get_count() > 0){
MessageBeep(MB_OK);
for(t_size i=0; i<_its.get_count(); i++){
_its.get_item(i)->
}
}

Here is the interesting part:
_its.get_item(i)-> ...
how to change the rating for this item ? Can anyone help ?

Thanks in advance smile.gif
Go to the top of the page
+Quote Post
foosion
post Jul 8 2011, 20:19
Post #2





Group: FB2K Moderator (Donating)
Posts: 4224
Joined: 24-February 03
Member No.: 5153



There is no method on metadb_handles for setting tags and the foo_playcount component does not provide an API through which you could set the rating. You could execute the context menu command from foo_playcount, but doing that programmatically is a bit of a challenge.


--------------------
http://foosion.foobar2000.org/ - my components for foobar2000
Go to the top of the page
+Quote Post
orbbu
post Jul 8 2011, 21:40
Post #3





Group: Members
Posts: 7
Joined: 7-July 11
Member No.: 92106



I see, here is the incomplete command that I think I should use:

menu_helpers::run_command_context(standard_commands::guid_context_save_playlist, standard_commands::guid_context_save_playlist, _its);

But I need to replace "standard_commands::guid_context_save_playlist" with the GUID of the "set rating to 1"
I can't find in the documentation that GUID... can you please help ?

Thanks smile.gif
Go to the top of the page
+Quote Post
eyebex
post Jul 8 2011, 23:08
Post #4





Group: Members
Posts: 36
Joined: 23-May 05
Member No.: 22234



I've been looking into the exact same problem. What I'm doing until now is

CODE
GUID command,subcommand;
bool result=menu_helpers::find_command_by_name("Playback Statistics/Rating",command);
result=menu_helpers::run_command_context_playlist(command,subcommand);

Unfortunately, find_command_by_name() doesn't seem to work for context menus which have more than two levels, i.e. calling it with "Playback Statistics/Rating/1" does not work. So I only have the GUID of the "Rating" menu (15D9655C-F6DE-4B98-8942-A9DAE2F9AD75), but not the one of the "1" action.
Go to the top of the page
+Quote Post
foosion
post Jul 9 2011, 13:48
Post #5





Group: FB2K Moderator (Donating)
Posts: 4224
Joined: 24-February 03
Member No.: 5153



QUOTE (orbbu @ Jul 8 2011, 21:40) *
I can't find in the documentation that GUID... can you please help ?
That GUID is not part of the documentation of foo_playcount. Strictly speaking it is an implementation detail. However since changing it would also invalidate keyboard shortcuts for that command, it is safe to assume that it will stay fairly stable.

QUOTE (eyebex @ Jul 8 2011, 23:08) *
Unfortunately, find_command_by_name() doesn't seem to work for context menus which have more than two levels, i.e. calling it with "Playback Statistics/Rating/1" does not work.
The problem is that this helper function will not find dynamic menu commands, i.e. commands with a non-null subcommand GUID. (By the way, you'd better initialise that subcommand variable there. Use pfc::guid_null if you don't have a concrete subcommand GUID.)


--------------------
http://foosion.foobar2000.org/ - my components for foobar2000
Go to the top of the page
+Quote Post
eyebex
post Jul 9 2011, 14:04
Post #6





Group: Members
Posts: 36
Joined: 23-May 05
Member No.: 22234



QUOTE (foosion @ Jul 9 2011, 14:48) *
The problem is that this helper function will not find dynamic menu commands, i.e. commands with a non-null subcommand GUID.

Oh, I wouldn't have expected the Rating submenu to be dynamic. The content seems pretty static to me. Well, anyway, so how do I find out the GUIDs of the "1" ... "5" subcommands so I can execute them programmatically?

QUOTE (foosion @ Jul 9 2011, 14:48) *
(By the way, you'd better initialise that subcommand variable there. Use pfc::guid_null if you don't have a concrete subcommand GUID.)

Sure! That was just some example code and I left the subcommand variable uninitialized to indicate that I don't know what to fill in there.

Thanks!
Go to the top of the page
+Quote Post
marc2003
post Jul 9 2011, 14:08
Post #7





Group: Members
Posts: 3340
Joined: 27-January 05
From: England
Member No.: 19379



foo_uie_wsh_panel_mod can trigger dynamic context menu items based on text matching so a workaround must be in the source somewhere:

http://code.google.com/p/foo-wsh-panel-mod...e_wsh_panel_mod

sorry i'm not a developer so i wouldn't know where to begin looking.
Go to the top of the page
+Quote Post
eyebex
post Jul 9 2011, 14:44
Post #8





Group: Members
Posts: 36
Joined: 23-May 05
Member No.: 22234



QUOTE (marc2003 @ Jul 9 2011, 15:08) *

Thanks, its helpers::execute_context_command_by_name() looks quite promising, I'll take a look at it.
Go to the top of the page
+Quote Post
orbbu
post Jul 9 2011, 20:28
Post #9





Group: Members
Posts: 7
Joined: 7-July 11
Member No.: 92106



Thanks its working smile.gif
By using this:

if (!find_context_command_recur("1", dummy, cm->get_root(), node))

for "set rating to 1"
That's not really clean, as there might be others actions in the futur labeled "1", but it does the job smile.gif
Go to the top of the page
+Quote Post
Zao
post Jul 9 2011, 21:16
Post #10





Group: Members (Donating)
Posts: 779
Joined: 25-September 03
From: Umeå, Sweden
Member No.: 9001



Please don't ever release or redistibute anything containing such horrible hacks.


--------------------
Zao shang yong zao nong zao rang zao ren zao.
To, early in the morning, use a chisel to build a bathtub makes impatient people hot-tempered.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 20th June 2013 - 01:02