void Scrobbler::trackStarted( const Tomahawk::result_ptr& track ) { Q_ASSERT( QThread::currentThread() == thread() ); // qDebug() << Q_FUNC_INFO; if( m_reachedScrobblePoint ) { m_reachedScrobblePoint = false; scrobble(); } Tomahawk::InfoSystem::InfoCriteriaHash trackInfo; trackInfo["title"] = track->track(); trackInfo["artist"] = track->artist()->name(); trackInfo["album"] = track->album()->name(); trackInfo["duration"] = QString::number( track->duration() ); Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_scInfoIdentifier, Tomahawk::InfoSystem::InfoSubmitNowPlaying, QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) ); m_scrobblePoint = ScrobblePoint( track->duration() / 2 ); }
void Scrobbler::trackStarted( const Tomahawk::result_ptr& track ) { Q_ASSERT( QThread::currentThread() == thread() ); if ( m_reachedScrobblePoint ) { m_reachedScrobblePoint = false; scrobble(); } Tomahawk::InfoSystem::InfoStringHash trackInfo; trackInfo["title"] = track->track(); trackInfo["artist"] = track->artist()->name(); trackInfo["album"] = track->album()->name(); trackInfo["duration"] = QString::number( track->duration() ); trackInfo["albumpos"] = QString::number( track->albumpos() ); QVariantMap playInfo; playInfo["trackinfo"] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ); playInfo["private"] = TomahawkSettings::instance()->privateListeningMode(); Tomahawk::InfoSystem::InfoPushData pushData ( s_scInfoIdentifier, Tomahawk::InfoSystem::InfoSubmitNowPlaying, playInfo, Tomahawk::InfoSystem::PushNoFlag ); Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData ); // liblastfm forces 0-length tracks to scrobble after 4 minutes, stupid. if ( track->duration() == 0 ) m_scrobblePoint = ScrobblePoint( 30 ); else m_scrobblePoint = ScrobblePoint( track->duration() / 2 ); }
void LastFmService::slot_state_changed() { Debug::debug() << " [LastFmService] slot_state_changed " << m_currentTrack; if ( m_engineOldState == ENGINE::PAUSED && Engine::instance()->state() == ENGINE::PLAYING) { if (m_currentTrack) m_unpauseTime = QDateTime::currentDateTime().toTime_t(); } else if ( m_engineOldState == ENGINE::PLAYING && Engine::instance()->state() == ENGINE::PAUSED) { if (m_currentTrack) m_playbackLength += QDateTime::currentDateTime().toTime_t() - m_unpauseTime; } else if ( Engine::instance()->state() == ENGINE::STOPPED ) { if (m_currentTrack) scrobble(); /* unset current track */ m_currentTrack = MEDIA::TrackPtr(0); } m_engineOldState = Engine::instance()->state(); }
void StopWatch::onFrameChanged( int frame ) { if ( !m_scrobbled && static_cast<uint>(frame) >= (m_point * 1000) ) { emit scrobble(); m_scrobbled = true; } }
void ScrobbleService::onTrackStarted(const Track& t, const Track& oldtrack) { // This stops the loving of tracks in the recent tracks list affecting the current track #pragma message ( "check this list //disconnect( m_currentTrack.signalProxy(), SIGNAL(loveToggled(bool)), this, SIGNAL(lovedStateChanged(bool)) );" ) state = Playing; Q_ASSERT(m_connection); //TODO move to playerconnection if(t.isNull()) { qWarning() << "Can't start null track!"; return; } m_currentTrack = t; double trackLengthPercent = unicorn::UserSettings().value( "scrobblePoint", 50 ).toDouble() / 100.0; //This is to prevent the next track being scrobbled //instead of the track just listened if ( trackLengthPercent == 100 && !oldtrack.isNull() ) { m_trackToScrobble = oldtrack; } else { m_trackToScrobble = t; } ScrobblePoint timeout( m_currentTrack.duration() * trackLengthPercent ); delete m_watch; m_watch = new StopWatch(m_currentTrack.duration(), timeout); m_watch->start(); connect( m_watch, SIGNAL(scrobble()), SLOT(onScrobble())); connect( m_watch, SIGNAL(paused(bool)), SIGNAL(paused(bool))); connect( m_watch, SIGNAL(frameChanged( int )), SIGNAL(frameChanged( int ))); connect( m_watch, SIGNAL(timeout()), SIGNAL(timeout())); qDebug() << "********** AS = " << m_as; if( m_as ) { m_as->submit(); if ( scrobblableTrack( t ) ) { qDebug() << "************** Now Playing.."; m_as->nowPlaying( t ); } } }
void Scrobbler::trackStopped() { Q_ASSERT( QThread::currentThread() == thread() ); if ( m_reachedScrobblePoint ) { m_reachedScrobblePoint = false; scrobble(); } }
void StopWatch::onFrameChanged( int /*frame*/ ) { emit frameChanged( m_timeline->currentTime() ); if ( !m_scrobbled && elapsed() >= (m_point * 1000) ) { emit scrobble(); m_scrobbled = true; } }
LastFmService::~LastFmService() { Debug::debug() << " [LastFmService] delete"; if(SETTINGS()->_useLastFmScrobbler && isAuthenticated()) scrobble(); //! save settings QSettings settings(UTIL::CONFIGFILE,QSettings::IniFormat,this); settings.beginGroup("Scrobbler"); settings.setValue("username", LastFm::GLOBAL::username); settings.setValue("key", LastFm::GLOBAL::session_key); settings.endGroup(); settings.sync(); }
void LastFmService::slot_track_changed() { Debug::debug() << " [LastFmService] slot_track_changed " << m_currentTrack; if (m_currentTrack) scrobble(); m_currentTrack = Engine::instance()->playingTrack(); /* init time counter */ m_playbackStart = QDateTime::currentDateTime().toTime_t(); m_playbackLength = 0; m_unpauseTime = m_playbackStart; nowPlaying(); }
/* Thread: worker */ int lastfm_scrobble(int id) { DPRINTF(E_DBG, L_LASTFM, "Got LastFM scrobble request\n"); // LastFM is disabled because we already tried looking for a session key, but failed if (lastfm_disabled) return -1; // No session key in mem or in db if (!lastfm_session_key) lastfm_session_key = db_admin_get("lastfm_sk"); if (!lastfm_session_key) { DPRINTF(E_INFO, L_LASTFM, "No valid LastFM session key\n"); lastfm_disabled = 1; return -1; } return scrobble(id); }
void Player::scrobblingToggled(bool enabled) { Settings::instance()->setScroblingEnabled(enabled); if (enabled) { if (Settings::instance()->lastFMUser().isEmpty() || Settings::instance()->lastFMSession().isEmpty()) _lastFMDialog->show(); connect(_player, SIGNAL(prefinishMarkReached(qint32)), Scrobbler::instance(), SLOT(scrobble())); connect(Scrobbler::instance(), SIGNAL(scrobblerError(int,QString)), this, SLOT(scrobblerError(int,QString))); } else {