Track DragMimeData::track() const { MutableTrack track; track.setArtist( QString::fromUtf8( data( "item/artist" ) ) ); track.setTitle( QString::fromUtf8( data( "item/track" ) ) ); track.setAlbum( QString::fromUtf8( data( "item/album" ) ) ); return track; }
void LocalRqlTrackCallback::trackOk(const char* title, const char* album, const char* artist, const char* url, unsigned duration) { MutableTrack mt; mt.setTitle( QString::fromUtf8( title ) ); mt.setAlbum( QString::fromUtf8( album ) ); mt.setArtist( QString::fromUtf8( artist ) ); mt.setUrl( QString::fromUtf8( url ) ); mt.setDuration( duration ); emit track( mt ); delete this; }
FirehoseItem::FirehoseItem( const WsDomElement& e ) : m_user( e["user"]["name"].text() ) { static WsAccessManager* nam = 0; if (!nam) nam = new WsAccessManager; MutableTrack t; t.setArtist( e["track"]["artist"]["name"].text() ); t.setTitle( e["track"]["name"].text() ); m_track = t; QNetworkReply* r = nam->get( QNetworkRequest( e["user"]["image"].text() ) ); connect( r, SIGNAL(finished()), SLOT(onAvatarDownloaded()) ); }
void UnitTestsFingerprintIdRequest::testValidMp3() { MutableTrack t; t.setUrl( QUrl::fromLocalFile( "../lib/fingerprint/tests/data/05 - You Lot.mp3" ) ); t.setAlbum( "Blue Album" ); t.setArtist( "Orbital" ); t.setTitle( "You Lot" ); t.setDuration( 427 ); t.setTrackNumber( 5 ); FingerprintIdRequest f( t ); QSignalSpy spy( &f, SIGNAL(FpIDFound( QString )) ); QTest::qWait( 5000 ); QVERIFY2( spy.count() == 1, "Did not receive FpIdFound signal" ); QVERIFY( spy.takeFirst().takeFirst().toString() != "0" ); }
Track PlayerCommandParser::extractTrack( const QMap<QChar, QString>& args ) { MutableTrack track; track.setArtist( args['a'] ); track.setTitle( args['t'] ); track.setAlbum( args['b'] ); track.setMbid( Mbid( args['m'] ) ); track.setDuration( args['l'].toInt() ); track.setUrl( QUrl::fromLocalFile( QUrl::fromPercentEncoding( args['p'].toUtf8() ) ) ); track.setSource( Track::Player ); track.setExtra( "playerId", args['c'] ); //TODO should be done earlier, NOTE don't get the plugin to send a stamp // time as this is prolly unecessary, and I bet you get new bugs! track.stamp(); return track; }
void SpotifyListenerWin::loop() { m_windowTitle.clear(); EnumWindows( SpotifyListenerWin::callback, reinterpret_cast<LPARAM>(this) ); // stopped = // paused = Spotify // playing = Spotify - Allo, Darlin' – Kiss Your Lips State playerState = Stopped; if ( m_windowTitle.startsWith( "Spotify" ) ) { if ( !m_connection ) emit newConnection( m_connection = new SpotifyConnection ); QRegExp re( QString( "^Spotify - (.+) %1 (.+)").arg( QChar( 0x2013 ) ), Qt::CaseSensitive, QRegExp::RegExp2 ); playerState = re.indexIn( m_windowTitle ) == 0 ? Playing : Paused; if ( m_lastPlayerState != playerState ) { if ( playerState == Stopped ) { m_connection->stop(); m_lastTrack = Track(); } else if ( playerState == Paused ) { if ( m_lastPlayerState == Playing ) m_connection->pause(); } else if ( playerState == Playing ) { MutableTrack t; t.setTitle( re.capturedTexts().at( 2 ) ); t.setArtist( re.capturedTexts().at( 1 ) ); // we don't know the duration, but we don't display it so just guess t.setDuration( 320 ); if ( m_lastPlayerState == Paused && t == m_lastTrack ) m_connection->resume(); else m_connection->start( t ); m_lastTrack = t; } } else if ( playerState == Playing ) { // when going from one song to the next we stay in the play state MutableTrack t; t.setTitle( re.capturedTexts().at( 2 ) ); t.setArtist( re.capturedTexts().at( 1 ) ); // we don't know the duration, but we don't display it so just guess t.setDuration( 320 ); if ( t != m_lastTrack ) m_connection->start( t ); m_lastTrack = t; } } else { if ( m_lastPlayerState == Playing || m_lastPlayerState == Paused ) m_connection->stop(); delete m_connection; } m_lastPlayerState = playerState; }