User Tools

Site Tools


developer_center:recipe_book:extensions_and_core:playlist_buttons_aka_playlist_commands:advanced_command_creation_how_to_make_non-action_type_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer_center:recipe_book:extensions_and_core:playlist_buttons_aka_playlist_commands:advanced_command_creation_how_to_make_non-action_type_commands [2013/12/28 09:43] (current)
geekshadow created
Line 1: Line 1:
 +====== Advanced Command Creation (How to make non-action type commands) ======
  
 +If you just want to add a button that triggers a specific function you should probably consider the Playlist Commands Helper which is designed to expedite simple command creation.
 +However, if you need to create a command that isn't so simple you'll need to do it without the playlist commands helper. ​ The first thing you'll need to do is create a hollow PlaylistCommandsBuilder that we'll make into the command or commands you want.
 +
 +<​code>​
 +  /* C++, create a hollow sbIPlaylistCommandsBuilder */
 +  nsresult rv;
 +  nsCOMPtr<​sbiplaylistcommandsbuilder>​ newCommand =
 +    do_CreateInstance("​@songbirdnest.com/​Songbird/​PlaylistCommandsBuilder;​1",​
 +                      &rv);
 +  NS_ENSURE_SUCCESS(rv,​ rv);
 +
 +  // set the id of the newly created playlist command
 +  rv = newCommand->​Init("​my-super-awesome-command"​);​
 +  NS_ENSURE_SUCCESS(rv,​ rv);
 +
 +  /* Javascript, create a hollow sbIPlaylistCommandsBuilder */
 +  const PlaylistCommandsBuilder = new Components.
 +    Constructor("​@songbirdnest.com/​Songbird/​PlaylistCommandsBuilder;​1",​
 +                "​sbIPlaylistCommandsBuilder",​ "​init"​);​
 +
 +  // create and set the id of the new holllow command
 +  var newCommand = new PlaylistCommandsBuilder("​my-super-awesome-command"​);​
 +</​code>​
 +
 +Once we've got a hollow command object, we can start specializing it by adding one or more of the command types. For example, if we wanted to create a new submenu we would need to append a submenu command type to newCommand
 +
 +<​code>​
 +  /* C++, add a submenu */
 +  newCommand->​AppendSubmenu(
 +            (SBVoidString(),​ // a submenu id if we wanted this submenu to go into one, but we don't
 +             ​NS_LITERAL_STRING('​my-submenu'​),​ // an id for the submenu itself
 +             ​NS_LITERAL_STRING('​Submenu For Stuff'​),​ // a user-facing label
 +             ​NS_LITERAL_STRING('​Tooltips are unused'​)) // an unused tooltip
 +
 +  /* Javascript, add a submenu */
 +  newCommand.appendSubmenu
 +            (null, // a submenu id if we wanted this submenu to go into one, but we don't
 +             '​my-submenu',​ // an id for the submenu itself, the parent command
 +             '​Submenu For Stuff',​ // a user-facing label
 +             '​Tooltips are unused'​) // an unused tooltip
 +</​code>​
 + 
 +Each command object can support multiple commands within itself, and you can control where commands appear relative to one another using insert*Before and insert*After. ​
 +With this command created, the next step is to register it to a medialist or medialists. ​ See the Playlist Commands Manager section for more information.
developer_center/recipe_book/extensions_and_core/playlist_buttons_aka_playlist_commands/advanced_command_creation_how_to_make_non-action_type_commands.txt ยท Last modified: 2013/12/28 09:43 by geekshadow