Debian Codegraph @

demos/demo3.cpp

raw symbols SCIP
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
7 #include "Audioscrobbler.h"
8 #include "ws.h"
9 #include "Track.h"
10
11
12 #include <QtCore>
13 #include <QtNetwork>
14
15
16 struct MyCoreApp : QCoreApplication
17 {
18 Q_OBJECT
19
20 public:
21 MyCoreApp( int& argc, char** argv ) : QCoreApplication( argc, argv )
22 {}
23
24 public Q_SLOTS:
25 void onStatus( int status )
26 {
27 qDebug() << lastfm::Audioscrobbler::Status(status);
28 }
29 };
30
31
32 int main( int argc, char** argv )
33 {
34 // all 6 of these lines are REQUIRED in order to scrobble
35 // this demo requires you to fill in the blanks as well...
36 lastfm::ws::Username = "";
37 lastfm::ws::ApiKey = "";
38 lastfm::ws::SharedSecret = "";
39 lastfm::ws::SessionKey = ""; // you need to auth to get this... try demo2
40 QCoreApplication::setApplicationName( "liblastfm" );
41
42 MyCoreApp app( argc, argv );
43
44 lastfm::MutableTrack t;
45 t.setArtist( "Max Howell" );
46 t.setTitle( "I Told You Not To Trust Me With Your Daughter" );
47 t.setDuration( 30 );
48 t.stamp(); //sets track start time
49
50 lastfm::Audioscrobbler as( "ass" );
51 as.nowPlaying( t );
52 // Audioscrobbler will submit whatever is in the cache when you call submit.
53 // And the cache is persistent between sessions. So you should cache at the
54 // scrobble point usually, not before
55 as.cache( t );
56
57 QTimer timer;
58 timer.setSingleShot( true );
59 timer.setInterval( 31*1000 );
60 connect( &timer, SIGNAL(timeout()), &as, SLOT(submit()) );
61 timer.start();
62
63 app.connect( &as, SIGNAL(status(int)), SLOT(onStatus(int)) );
64
65 return app.exec();
66 }
67
68
69 #include "demo3.moc"