/thirdparty/liblastfm2/demos/demo3.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 63 lines · 38 code · 14 blank · 11 comment · 0 complexity · ed88b01f8ce6e150dffbc0768555d85e MD5 · raw file

  1. /*
  2. This software is in the public domain, furnished "as is", without technical
  3. support, and with no warranty, express or implied, as to its usefulness for
  4. any purpose.
  5. */
  6. #include <lastfm.h>
  7. #include <QtCore>
  8. #include <QtNetwork>
  9. #include "src/_version.h"
  10. struct MyCoreApp : QCoreApplication
  11. {
  12. Q_OBJECT
  13. public:
  14. MyCoreApp( int& argc, char** argv ) : QCoreApplication( argc, argv )
  15. {}
  16. public slots:
  17. void onStatus( int status )
  18. {
  19. qDebug() << lastfm::Audioscrobbler::Status(status);
  20. }
  21. };
  22. int main( int argc, char** argv )
  23. {
  24. // all 6 of these lines are REQUIRED in order to scrobble
  25. // this demo requires you to fill in the blanks as well...
  26. lastfm::ws::Username =
  27. lastfm::ws::ApiKey =
  28. lastfm::ws::SharedSecret =
  29. lastfm::ws::SessionKey = // you need to auth to get this... try demo2
  30. QCoreApplication::setApplicationName( "liblastfm" );
  31. QCoreApplication::setApplicationVersion( VERSION );
  32. MyCoreApp app( argc, argv );
  33. lastfm::MutableTrack t;
  34. t.setArtist( "Max Howell" );
  35. t.setTitle( "I Told You Not To Trust Me With Your Daughter" );
  36. t.setDuration( 30 );
  37. t.stamp(); //sets track start time
  38. lastfm::Audioscrobbler as( "ass" );
  39. as.nowPlaying( t );
  40. // Audioscrobbler will submit whatever is in the cache when you call submit.
  41. // And the cache is persistent between sessions. So you should cache at the
  42. // scrobble point usually, not before
  43. as.cache( t );
  44. //FIXME I don't get it, but the timer never triggers! pls fork and fix!
  45. QTimer::singleShot( 31*1000, &as, SLOT(submit()) );
  46. app.connect( &as, SIGNAL(status(int)), SLOT(onStatus(int)) );
  47. return app.exec();
  48. }
  49. #include "demo3.moc"