Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: foobar web interface (Read 10957 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foobar web interface

hey, i just need to know...

1. how to get the current time of the track (in 00:00 format if you can)
2. get the current playstring ("file://c:/somewere/somthing.mp3")
3. get the number of playlist items
4. get the CURRENT name to ANY playlist item by its place in the list (get(13) = "13. Less Than Jake - Gainsville Rock City")

can someone help me out please :-)

thanks

foobar web interface

Reply #1
play_control.h
playlist.h

foobar web interface

Reply #2
In other words, RTFM, C_G?  Not very helpful, especially in the Development forum...   

1.
Code: [Select]
double elapsedSongSeconds = 0;
play_control::command(play_control::PLAYBACK_GETPOS, (int)&elapsedSongSeconds);

That gives you the elapsed time, in seconds.  Then you can convert that to hours, minutes, seconds:

const unsigned int ehours = (unsigned int)(elapsedSongSeconds / 3600);
const unsigned int emins  = (unsigned int)(elapsedSongSeconds / 60) % 60;
const unsigned int esecs  = elapsedSongSeconds % 60;

and convert it to a string using snprintf().



2. You can get a lot of information by using metadb::format_title() and the right format string.  This is what I use - it uses CString, but it wouldn't be hard to convert to the string of your choice.  Also, there is now a metadb_handle::handle_format_title(), so you can get a format directly from a metadb_handle*, so some of the following code is unnecessary but I never bothered to update it...
Code: [Select]
metadb_handle* GetCurrentSongHandle()
{
    metadb_handle *handle = play_control::get()->get_now_playing();    
    if(!handle)
 handle = playlist_oper::get()->get_item(playlist_oper::get()->get_focus());
    return(handle);
}

void GetCurrentSongTitle(CString &string, LPCTSTR format)
{
    string.Empty();
    
    metadb_handle *handle = GetCurrentSongHandle();
    if(!handle || !format)
 return;

    const playlist_entry *entry = handle->handle_get_location();
    if(entry)
    {
 string_interface_i str;

 metadb::get()->format_title(entry, &str, string_utf8_from_os(format), NULL, NULL);

 if(str.get_ptr())
     string = string_os_from_utf8(str.get_ptr());
    }

    handle->handle_release();
}

Next you need to find the correct format string...for this, go to Foobar Preferences, and then to Display->Title Formatting.  Click on the Help button, and there is the syntax reference.  So to get the currently playing or selected song, you would want: GetCurrentSongTitle(string, "%_path%");.  format_title() is very powerful and lets you get a lot of information about a file and format it.



3. playlist_oper::get()->get_count();



4. playlist_oper::get()->get_item(index);  That will return you a metadb_handle*, which is exactly what you need for metadb_handle::handle_format_title().  Apply the right format string (something like: %_playlist_number%. %artist% - %title%), and you'll get your desired output. 


Good luck with your HTTP interface!  I ported my Winamp2 HTTP server/interface over to Foobar a while ago, but due to commercial interest, I haven't released it as a publically available Foobar component.  I'm looking forward to your component, however! 




[Edit]
1: Fixed a paste-o in the GetCurrentSongTitle() function.
2: These instructions are for the Foobar 0.667 SDK...things might be different in 0.7.

foobar web interface

Reply #3
Quote
Good luck with your HTTP interface!  I ported my Winamp2 HTTP server/interface over to Foobar a while ago, but due to commercial interest, I haven't released it as a publically available Foobar component.

Hey, weren't you the guy who was complaining about the more restrictive licence of fb2k 0.7?     
A riddle is a short sword attached to the next 2000 years.

foobar web interface

Reply #4
Quote
In other words, RTFM, C_G?  Not very helpful, especially in the Development forum...  

Meh.  Those things seemed fairly obvious to me (except number 4).  I thought a push in the right direction would be enough.

foobar web interface

Reply #5
Quote
Quote
Good luck with your HTTP interface!  I ported my Winamp2 HTTP server/interface over to Foobar a while ago, but due to commercial interest, I haven't released it as a publically available Foobar component.

Hey, weren't you the guy who was complaining about the more restrictive licence of fb2k 0.7?     

If by complaining, you really mean pointing out the new, less free license, then yes.  One of things that attracted me to the pre-0.7 Foobar is the BSD style license, which among other things, allows for the freedom to use Foobar for commercial projects (with proper credit, of course).

I'm also the guy who wrote and gave away foo_ufts, foo_bookmark, and instead of just posting meh and RTFM, answered Bizzy D's questions.  But that's me - all take and no give...  B)

foobar web interface

Reply #6
I did not post 'meh' or RTFM in response to Bizzy's request.  The 'meh' was directed at you.  I still think that pointing Bizzy toward the appropriate headers should have been enough.  In addition, I don't really think your answers were appropriate.  They are centered around 0.6.  I would assume that anyone developing a new plugin would be developing for 0.7 (but perhaps I'm not correct in this assumption).

And giving away foo_utfs and foo_bookmark?  You haven't released the code, which means that you haven't released anything for other developers to actually use.  I've got nothing against you, and I certainly don't think that you are obliged to release any code.  But you seem to be a bit condescending.

If my pointers were not enough (and you are developing for 0.7):
1:
play_control.h
virtual double get_playback_time()=0; <- I believe this returns seconds.

Code: [Select]
double time = play_control::get()->get_playback_time();
int seconds  = ((int)time) % 60;
time /= 60;
int minutes = ((int)time) % 60;
time /= 60;
int hours = (int)time);

string8 meh; // use string_printf if you prefer
meh.add_int(hours);
meh.add_char(':');
meh.add_int(minutes);
meh.add_char(':');
meh.add_int(seconds);


2:
play_control.h
virtual metadb_handle * get_now_playing()=0;

Code: [Select]
metadb_handle * handle = play_control::get()->get_now_playing();
if (handle)
{
   const char * path = handle->handle_get_path(); // file://c:\meh.mp3
   string8 path2(path + 7); // c:\meh.mp3
}


3:
playlist.h
virtual int get_count()=0;

Code: [Select]
int num = playlist_oper::get()->get_count();


4:
playlist.h
virtual void format_title(int idx,string_interface * out,const char * spec,const char * extra_items)=0;//spec may be null, will use core settings; extra items are optional

Code: [Select]
string_interface_i title; // found in interface_helper.h
int num = playlist_oper::get()->get_count();
for (int i = 0; i < num; i++)
{
   format_title(i,&title,NULL,NULL);
   // do whatever here
}

foobar web interface

Reply #7
Quote
I did not post 'meh' or RTFM in response to Bizzy's request.  The 'meh' was directed at you.  I still think that pointing Bizzy toward the appropriate headers should have been enough

My meh comment was more a reflection on your general attitude.  Just posting a couple of header filenames (read: RTFM) really isn't helping a new developer.

Quote
In addition, I don't really think your answers were appropriate.  They are centered around 0.6.  I would assume that anyone developing a new plugin would be developing for 0.7 (but perhaps I'm not correct in this assumption).

Of course, I noted that the responses were targeted to 0.667.  Why steer a new developer to develop their first component for the moving target 0.7 SDK when it is so much easier to get it working on the stable 0.667 binary and SDK, and port it to 0.7 when/if necessary?

Quote
And giving away foo_utfs and foo_bookmark?  You haven't released the code, which means that you haven't released anything for other developers to actually use.  I've got nothing against you, and I certainly don't think that you are obliged to release any code.  But you seem to be a bit condescending.

Condescending?  Meh...  I have released those binaries without restriction, and helped many other developers - both in the forums and privately, by supplying source code from those projects and others. 

My point was responding to ssamadhi97 insinuation that I was being hypocritical for having an unreleased commercial component while complaining about the new Foobar 0.7 license.  I was merely pointing out that in addition to that, I have also made a lot of work and help freely available to the Foobar users.

foobar web interface

Reply #8
1: you should be able to use string_print_time() from string.h to format the time.. at least it will follow foobar's behaviour with weeks and days etc.
.

foobar web interface

Reply #9
ok, just thought i would throw in a little beta....

it just has basic controls (prev, play, stop, pause (doesnt work for some reason), next)
theres a refresh (just to get updates)
it shows the current file being played
it shows the current time, and actual formated track name (just ripped from the window title)

im gonna do the playlist as soon as i get chance

also, im gonna try and make it as configurable as possible,

also, is there a way of getting the current version of foobar?

Bizzy

Download (check out the ini file  btw, it goes in the components dir with the dll)

foobar web interface

Reply #10
Quote
also, is there a way of getting the current version of foobar?

Kind of.

The following should work, but it's kind of lame. (I don't know of any other way, though)
Code: [Select]
string8 version;
metadb::g_format_title(&make_playable_location("c:\meh.mp3"),version,"%_foobar2000_version%");


Just in case you don't know, major versions (e.g. 0.6, 0.7) are completely incompatable with each other, so you needn't worry about problems arising there.  The plugin will simply fail to load.

foobar web interface

Reply #11
Quote
ok, just thought i would throw in a little beta....

it just has basic controls (prev, play, stop, pause (doesnt work for some reason), next)
theres a refresh (just to get updates)
it shows the current file being played
it shows the current time, and actual formated track name (just ripped from the window title)

im gonna do the playlist as soon as i get chance

also, im gonna try and make it as configurable as possible,

also, is there a way of getting the current version of foobar?

Bizzy

Download (check out the ini file  btw, it goes in the components dir with the dll)

ok, /me feels stupid but, how do you use it??
"You have the right to remain silent. Anything you say will be misquoted, then used against you."

foobar web interface

Reply #12
to use it u install it (duh) then in a web browser of ur choice visit http://ip-of-foobar-machine:[port (defualt = 8080)]

example = http://127.0.0.1:8080

to change the dafault, edit the ini...

im adding a CSS to it later, soon as i got the playlist bit working

on a side note, would you want each playlist item to be a hyperlink to play the file? or would u just want the playlist to be a list of test showing all the tracks?

foobar web interface

Reply #13
Quote
in a web browser of ur choice visit

I've tried Mozilla Firebird 0.6, Opera 7 and IE5, and it didn't work for me. It said either something about "connection refused", or nothing happened at all. This is on Win98SE. The plugin did load, and netstat shows it is listening on the configured port.

Quote
to change the dafault, edit the ini...

Oh, an ini file. Is this just because the plugin is still in beta phase, or because you don't know about the great fb2k configuration variables? In the latter case, you should have a look at pfc/cfg_var.h (private) and SDK/config_var.h (public). "Public" means other plugins will be able to read and write it.
At least I wish for some global options (like the used port) to be configurable in fb2k.

Quote
on a side note, would you want each playlist item to be a hyperlink to play the file? or would u just want the playlist to be a list of test showing all the tracks?

Make it configurable

edit: Please add console output to report errors and connection attemps (at least for beta versions).

foobar web interface

Reply #14
tested it on XP-SP1 on Mozilla Firebird 0.6, Opera 7 and IE5..
its built for 0.7b9 though... there is a reason for this too :-)
the ini i dont know about yet... i may change it, and i may not, it depends if i can be botherd... i was thinking about it cos GetPrivateProfileString is SLOW AS FUCK...
i dont know if theres any unicode stuff in it that would break 9x compatibility... i dont think there is...

anyway... i dont know how *configurable* im gonna let the look be... im thinking about using the CSS in the FAQ.htlm, just gotta make sure peters ok with me using it (new licence :S)

Bizzy

btw... i added some info and error stuff last night just after i posted the beta....
im also considering making it open source when i have finnished it... let people mod it to how they like it.... but.. we'll see...

foobar web interface

Reply #15
Works for me as well (WinXP SP0).

I'd say blame Win98 or the user..
A riddle is a short sword attached to the next 2000 years.

foobar web interface

Reply #16
Quote
to use it u install it (duh) then in a web browser of ur choice visit http://ip-of-foobar-machine:[port (defualt = 8080)]

example = http://127.0.0.1:8080

to change the dafault, edit the ini...

im adding a CSS to it later, soon as i got the playlist bit working

on a side note, would you want each playlist item to be a hyperlink to play the file? or would u just want the playlist to be a list of test showing all the tracks?

1. Thanks, (please add a readme, so no more ppl ask the same question)
2. I'd say hyperlinks for each song in the playlist.

The UI is great, one could make a Foobar sidebar for Mozilla...
It'd look (I think) nicer if you replaced the next/play/prev links with buttons.
"You have the right to remain silent. Anything you say will be misquoted, then used against you."

foobar web interface

Reply #17
I'd really like to have something like this.  Mind porting it to latest beta/0.667, or perhaps releasing the code?  It sounds like great work.

foobar web interface

Reply #18
Quote
In other words, RTFM, C_G?

Hey where is the FM anyways? Its not on the main foobar page. I've figured out how to do the basics by trial and error, but if there is a manual, I would like to read it
EAC -> LAME 3.90.3 --alt-preset standard -> album mp3gain
home: PC -> Stereo Link 1200 -> Shure e2c
mobile: iPod -> Koss Portapros

foobar web interface

Reply #19
The SDK "manual" is the collection of header and source files. Nothing like reading source code to understand how to use it.


foobar web interface

Reply #21
Any chance of someone making something like this again?  I think it would be a very useful plugin.