Skip to main content
Topic: Compiling (Read 5628 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Compiling

alright, i've been handed a code

Code: [Select]
#include "../SDK/foobar2000.h"
#include "../helpers/helpers.h"


/*-----------------------------------------------
Providing information about a component.
Viewed under Preferences > Components.
-------------------------------------------------*/
DECLARE_COMPONENT_VERSION(
// component name
"Playlist Context Menu Helpers",
// component version
"0.1.3",
// about text, use \n to separate multiple lines
// If you don't want any about text, set this parameter to NULL.
"Context menu playlist helpers\n"
"for foobar2000 v0.9\n"
"\n"
"contributors:\n"
"John Bell\n")



/*-----------------------------------------------
Component initialize and release
on_init is called after main window has been created,
on_quit is called before main window is destroyed
-------------------------------------------------*/
class initquit_foo_playlist_helpers : public initquit {

virtual void on_init()
{
// foobar2000 has a 'playing' playlist and an 'active' playlist
// force the playing playlist to "Now Playing"
static_api_ptr_t<playlist_manager> pm;
pfc::string8 playlist("Now Playing");
t_size play_ndx = pm->find_playlist(playlist, playlist.length());
pm->set_playing_playlist(play_ndx);
//pm->playback_order_set_active(0); //resets the order to start at the top
}

//virtual void on_quit() {}
};
static initquit_factory_t< initquit_foo_playlist_helpers > foo_initquit;


/*-----------------------------------------------
Context menu item implementations
-------------------------------------------------*/
class contextmenu_commands_foo_playlist_helpers : public contextmenu_item_simple
{
enum menu_index {
mnuSendToNowPlaying,
mnuAppendToNowPlaying
};

virtual unsigned get_num_items() {
return 2;
}

virtual GUID get_item_guid(unsigned p_index) {
static const GUID guid_context_send_to_now_playing = { 0xd3499f7c, 0xebf3, 0x4d98, { 0x94, 0xaf, 0x36, 0x5a, 0x95, 0x5d, 0x12, 0x2c } };
static const GUID guid_context_append_to_now_playing = { 0x6afbf8c0, 0x828f, 0x4d06, { 0xa4, 0x96, 0xa2, 0x39, 0x76, 0xe8, 0x6b, 0x8e } };

if( p_index == mnuSendToNowPlaying )
return guid_context_send_to_now_playing;

else if( p_index == mnuAppendToNowPlaying )
return guid_context_append_to_now_playing;

return pfc::guid_null;
}

virtual void get_item_name(unsigned p_index,pfc::string_base& p_out) {
if( p_index == mnuSendToNowPlaying )
p_out = "Send to Now Playing";
else if( p_index == mnuAppendToNowPlaying )
p_out = "Append to Now Playing";
}

virtual void get_item_default_path(unsigned p_index,pfc::string_base& p_out) {
if( p_index == mnuSendToNowPlaying )
p_out = "";
else if( p_index == mnuAppendToNowPlaying )
p_out = "";
}

virtual bool get_item_description(unsigned p_index,pfc::string_base& p_out) {
if( p_index == mnuSendToNowPlaying ) {
p_out = "Clears the Now Playing playlist and then sends the selected item(s) to the Now Playing playlist";
return true;
}
else if( p_index == mnuAppendToNowPlaying ) {
p_out = "Appends item(s) to the Now Playing playlist";
return true;
}
return false;
}

virtual void context_command(unsigned p_index,const pfc::list_base_const_t<metadb_handle_ptr>& p_data,const GUID& p_caller) {
if( core_api::assert_main_thread() )
{
if( p_index == mnuSendToNowPlaying || p_index == mnuAppendToNowPlaying )
{
static_api_ptr_t<playlist_manager> pm;
pfc::string8 playlist("Browser");
t_size browser_ndx = pm->find_playlist(playlist, playlist.length());
playlist = "Now Playing";
t_size play_ndx = pm->find_playlist(playlist, playlist.length());
metadb_handle_list list;
pm->playlist_get_selected_items(browser_ndx, list);
if( p_index == mnuSendToNowPlaying ) {
pm->set_playing_playlist(play_ndx);
pm->playlist_clear(play_ndx);
}
pm->playlist_add_items(play_ndx, list, bit_array_false());
}
}
}

};

// We need to create a service factory for our menu item class,
// otherwise the menu commands won't be known to the system.
static contextmenu_item_factory_t< contextmenu_commands_foo_playlist_helpers > foo_menu;


how do i turn this into a .dll

?

Compiling

Reply #1
thanks


ive got microsoft visual basic... hopefully itll work.

Compiling

Reply #2
okay... i have no idea what im doing.


Compiling

Reply #4
Disappointingly, the code snippet you posted isn't written in Visual Basic, so the Visual Basic compiler may be slightly confused.  It's written in C++ using the foobar2000 SDK.  Maybe you should look at the step-by-steps in the forum sticky?

EDIT:  That was a good guess.

Compiling

Reply #5
yea, i looked at the wikis about BASIC and C++, and basic looked a little closer to the code i had because of the $s and things

but C++ had the brackets and visual layout that was more similar





eh, hopefully itll work now (its installing)

Compiling

Reply #6
alright, it cant find ...\my documents\visual studio 2005\projects\foo_nowplaying\foo_nowplaying\foo_nowplaying.h

what do i do from here?

Compiling

Reply #7
alright, it cant find ...\my documents\visual studio 2005\projects\foo_nowplaying\foo_nowplaying\foo_nowplaying.h

what do i do from here?


You know what, I have some free time on my hands, so I'll try it out (I haven't used the FB2K SDK before) and get back to you.

Compiling

Reply #8
thanks, man.

Compiling

Reply #9
It was pretty easy for me to figure out (using Visual Studio 2005 with the SDK) but it would be nigh-impossible if you have never used VS2005 before and have no programming experience, so if you are really dedicated to doing it I hope you have plenty of time to learn.

Anyway, here's a DLL of that source (credit due to this guy, I believe) which works on my machine, FB2K 0.9.4.1.  Let me know if you have problems with it.

Compiling

Reply #10
Sorry to step in.

FB 0.9.4.2

I can see the two context menu commands but it seems they don't work.

Compiling

Reply #11
Sorry to step in.

FB 0.9.4.2

I can see the two context menu commands but it seems they don't work.


(I didn't actually test it, so beats me whether it works right, I just saw that it shows up and the context menu items are added.  Better take it up with that guy in the other thread if it doesn't work : )

EDIT:  Reading the source code, I noticed that the source playlist is hard-coded to "Browser" - that is, the context menu items won't do anything unless you are on a playlist named "Browser", in which case they will send your selected tracks on "Browser" to a playlist called "Now Playing", if it exists.  Maybe that's what your problem is.

Compiling

Reply #12
i have a shitload of computer experience in just about everything except hard coding (from visual to audio to http)

i can get up to where it can't find the .h, but i guess i'd need the SDK from the main foosite?


whatever, i'll see if yours works.

yea, it seems to work

 
SimplePortal 1.0.0 RC1 © 2008-2019