Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After reading a number of different sources of information (most of which were contradictory), I've found that the following results in a working solution - albeit with a cosmetic issue in the debugging output that doesn't seem to affect operation (<code>Object::connect: No such signal QNetworkReplyImpl::finished(QNetworkReply*) in ../AudioPlayer/scrobblemedia.cpp:29</code>):</p> <p>In <code>scrobblemedia.cpp</code>:</p> <pre><code>#include "scrobblemedia.h" #include &lt;QDebug&gt; #include &lt;cstdio&gt; ScrobbleMedia::ScrobbleMedia(QString asUsername, QString asPassword, QString asArtist, QString asTrack, QString asAlbum) { QByteArray iDataSink; QEventLoop iLoop; QString KEndPointURL = "http://lastfmstats.livefrombmore.com/universalscrobbler/scrobble.php"; QUrl iScrobbleEndPoint(KEndPointURL); iScrobbleEndPoint.addQueryItem("submissionType","track"); iScrobbleEndPoint.addQueryItem("username", asUsername); iScrobbleEndPoint.addQueryItem("password", asPassword); iScrobbleEndPoint.addQueryItem("artist", asArtist); iScrobbleEndPoint.addQueryItem("track", asTrack); iScrobbleEndPoint.addQueryItem("album", asAlbum); iScrobbleEndPoint.addQueryItem("number","1"); iScrobbleEndPoint.addQueryItem("duration","200"); QNetworkAccessManager iScrobbleDispatcher; QNetworkRequest iScrobbleRequest(iScrobbleEndPoint); QNetworkReply *iScrobbleReply = iScrobbleDispatcher.get(iScrobbleRequest); QObject::connect(iScrobbleReply, SIGNAL(finished(QNetworkReply*)), &amp;iLoop, SLOT(quit())); iDataSink = iScrobbleReply-&gt;readAll(); qDebug() &lt;&lt; "Received: " + asUsername + " " + asPassword + " " + asArtist + " " + asTrack + " " + asAlbum; qDebug() &lt;&lt; iScrobbleEndPoint.toString(); iLoop.exec(); } ScrobbleMedia::~ScrobbleMedia() { } void ScrobbleMedia::replyFinished(QNetworkReply*) { } void ScrobbleMedia::reallyDone() { qDebug() &lt;&lt; "We've probably successfully Scrobbled..."; } </code></pre> <p>In <code>scrobblemedia.h</code>:</p> <pre><code>#ifndef SCROBBLEMEDIA_H #define SCROBBLEMEDIA_H #include &lt;QString&gt; #include &lt;QtNetwork&gt; #include &lt;QUrl&gt; #include &lt;QNetworkAccessManager&gt; class ScrobbleMedia : public QObject { Q_OBJECT private: public: ScrobbleMedia(QString asUsername, QString asPassword, QString asArtist, QString asTrack, QString asAlbum); ~ScrobbleMedia(); private slots: void replyFinished(QNetworkReply*); void reallyDone(); }; #endif // SCROBBLEMEDIA_H </code></pre> <p>Thanks to everyone for their help. </p> <p>Hopefully this code will serve as a useful template for others, in the future.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload