You are not logged in.
Awesome, right documentation page, just wrong part of it. See my edit above.
Exploring those doc pages should help polish this project off.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Awesome, right documentation page, just wrong part of it. See my edit above.
Exploring those doc pages should help polish this project off.
Okay, as I said I will look into this tomorrow.
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
I really recommend the free ebook "C++: A Dialog" (it used to be called "Who's Afraid of C++?"). You can find it here:
http://www.steveheller.com/cppad/cppad.htm
It really goes from beginner to expert, as he discusses programming with a complete newbie.
Offline
I really recommend the free ebook "C++: A Dialog" (it used to be called "Who's Afraid of C++?"). You can find it here:
http://www.steveheller.com/cppad/cppad.htm
It really goes from beginner to expert, as he discusses programming with a complete newbie.
Thanks! But.. is C++ alot different than C?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Okay, as I said I will look into this tomorrow.
I am doing so at the moment but still can't get it to work Trilby, the code you suggested, e.g.
struct mpd_status *mystatus = mpd_recv_status(conn);
doesn't change a thing. Do I have to add something else? I already tried lots of things and am also spitting through those document pages I found, but yea... can't get it to work. Here's what I have atm:
...
struct mpd_status *mystatus = mpd_recv_status(conn);
if (mystatus == MPD_STATE_PLAY) {
mpd_response_next(conn);
song = mpd_recv_song(conn);
if ((title = g_markup_escape_text(mpd_song_get_tag(song, MPD_TAG_TITLE, 0), -1)) == NULL)
title = TEXT_UNKNOWN;
if ((artist = g_markup_escape_text(mpd_song_get_tag(song, MPD_TAG_ARTIST, 0), -1)) == NULL)
artist = TEXT_UNKNOWN;
if ((album = g_markup_escape_text(mpd_song_get_tag(song, MPD_TAG_ALBUM, 0), -1)) == NULL)
album = TEXT_UNKNOWN;
notification = (char *) malloc(strlen(TEXT_PLAY) + strlen(title) + strlen(artist) + strlen(album));
sprintf(notification, TEXT_PLAY, title, artist, album);
mpd_song_free(song);
}
else if (mystatus == MPD_STATE_PAUSE) {
notification = (char *) malloc(strlen(TEXT_PAUSE));
sprintf(notification, TEXT_PAUSE);
}
else {
notification = (char *) malloc(strlen(TEXT_STOP));
sprintf(notification, TEXT_STOP);
}
...
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
... struct mpd_status *mystatus = mpd_recv_status(conn); if (mystatus == MPD_STATE_PLAY) { mpd_response_next(conn); ...
You are comparing a state to a status. You need to compare states to states. You get the state using mpd_status_get_state and passing in the status ... Only after you know the status is valid.
I refer you to a quote from my previous post:
struct mpd_status* theStatus = mpd_recv_status(conn);
if ( ! theStatus)
/*Don't use a null pointer. You may want a more graceful error handler */
exit(1);
if (mpd_status_get_state(theStatus) == MPD_STATE_PLAY)
{
Edit: Fixed two minor code issues. It is a struct, not a typedef.
Last edited by ewaller (2012-06-13 21:59:55)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Sorry for not replying yesterday. I got to hear I passed my finals at High School so I was busy celebrating with friends and family (In case you wonder now, I'm 17 years old)
Today I fiddled around with the code a tad and suddenly got it working! I don't know how 'efficient' it is but at least it works!
In case anyone wants to use it too (or review the code ) here it is:
https://gist.github.com/2936589
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
That is a whole lot more complex than the code I was writing when I was your age. Well Done.
And, far more importantly, congratulations on the exams.
(Yikes, you are my daughter's age )
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
That is a whole lot more complex than the code I was writing when I was your age. Well Done.
And, far more importantly, congratulations on the exams.
(Yikes, you are my daughter's age
)
Thanks! And eh... got an email?
(joking, of course
)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline