PageRenderTime 82ms CodeModel.GetById 41ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

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