mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-14 01:54:07 +02:00
Set the timer with track duration calculated in
This commit is contained in:
@@ -36,8 +36,8 @@ using namespace Tomahawk;
|
||||
void
|
||||
DatabaseCommand_LogPlayback::postCommitHook()
|
||||
{
|
||||
connect( this, SIGNAL( trackPlaying( Tomahawk::query_ptr ) ),
|
||||
source().data(), SLOT( onPlaybackStarted( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
|
||||
connect( this, SIGNAL( trackPlaying( Tomahawk::query_ptr, unsigned int ) ),
|
||||
source().data(), SLOT( onPlaybackStarted( Tomahawk::query_ptr, unsigned int ) ), Qt::QueuedConnection );
|
||||
connect( this, SIGNAL( trackPlayed( Tomahawk::query_ptr ) ),
|
||||
source().data(), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
|
||||
|
||||
@@ -60,7 +60,7 @@ DatabaseCommand_LogPlayback::postCommitHook()
|
||||
// if the play time is more than 10 minutes in the past, ignore
|
||||
else if ( m_action == Started && QDateTime::fromTime_t( playtime() ).secsTo( QDateTime::currentDateTime() ) < STARTED_THRESHOLD )
|
||||
{
|
||||
emit trackPlaying( q );
|
||||
emit trackPlaying( q, m_trackDuration );
|
||||
}
|
||||
|
||||
if ( source()->isLocal() )
|
||||
|
@@ -37,6 +37,7 @@ Q_PROPERTY( QString artist READ artist WRITE setArtist )
|
||||
Q_PROPERTY( QString track READ track WRITE setTrack )
|
||||
Q_PROPERTY( unsigned int playtime READ playtime WRITE setPlaytime )
|
||||
Q_PROPERTY( unsigned int secsPlayed READ secsPlayed WRITE setSecsPlayed )
|
||||
Q_PROPERTY( unsigned int trackDuration READ trackDuration WRITE setTrackDuration )
|
||||
Q_PROPERTY( int action READ action WRITE setAction )
|
||||
|
||||
public:
|
||||
@@ -47,13 +48,14 @@ public:
|
||||
};
|
||||
|
||||
explicit DatabaseCommand_LogPlayback( QObject* parent = 0 )
|
||||
: DatabaseCommandLoggable( parent )
|
||||
: DatabaseCommandLoggable( parent ), m_playtime( 0 ), m_secsPlayed( 0 ), m_trackDuration( 0 )
|
||||
{}
|
||||
|
||||
explicit DatabaseCommand_LogPlayback( const Tomahawk::result_ptr& result, Action action, unsigned int secsPlayed = 0, QObject* parent = 0 )
|
||||
: DatabaseCommandLoggable( parent ), m_result( result ), m_secsPlayed( secsPlayed ), m_action( action )
|
||||
{
|
||||
m_playtime = QDateTime::currentDateTimeUtc().toTime_t();
|
||||
m_trackDuration = result->duration();
|
||||
setSource( SourceList::instance()->getLocal() );
|
||||
|
||||
setArtist( result->artist()->name() );
|
||||
@@ -82,11 +84,14 @@ public:
|
||||
unsigned int secsPlayed() const { return m_secsPlayed; }
|
||||
void setSecsPlayed( unsigned int i ) { m_secsPlayed = i; }
|
||||
|
||||
unsigned int trackDuration() const { return m_trackDuration; }
|
||||
void setTrackDuration( unsigned int trackDuration ) { m_trackDuration = trackDuration; }
|
||||
|
||||
int action() const { return m_action; }
|
||||
void setAction( int a ) { m_action = (Action)a; }
|
||||
|
||||
signals:
|
||||
void trackPlaying( const Tomahawk::query_ptr& query );
|
||||
void trackPlaying( const Tomahawk::query_ptr& query, unsigned int duration );
|
||||
void trackPlayed( const Tomahawk::query_ptr& query );
|
||||
|
||||
private:
|
||||
@@ -96,6 +101,7 @@ private:
|
||||
QString m_track;
|
||||
unsigned int m_playtime;
|
||||
unsigned int m_secsPlayed;
|
||||
unsigned int m_trackDuration;
|
||||
Action m_action;
|
||||
};
|
||||
|
||||
|
@@ -266,6 +266,7 @@ CREATE TABLE IF NOT EXISTS playback_log (
|
||||
playtime INTEGER NOT NULL, -- when playback finished (timestamp)
|
||||
secs_played INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX playback_log_source ON playback_log(source);
|
||||
CREATE INDEX playback_log_track ON playback_log(track);
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
This file was automatically generated from schema.sql on Thu Sep 29 17:28:17 EDT 2011.
|
||||
This file was automatically generated from schema.sql on Wed Nov 16 22:47:16 EST 2011.
|
||||
*/
|
||||
|
||||
static const char * tomahawk_schema_sql =
|
||||
|
@@ -59,7 +59,6 @@ Source::Source( int id, const QString& username )
|
||||
m_online = true;
|
||||
}
|
||||
|
||||
m_currentTrackTimer.setInterval( 600000 ); // 10 minutes
|
||||
m_currentTrackTimer.setSingleShot( true );
|
||||
connect( &m_currentTrackTimer, SIGNAL( timeout() ), this, SLOT( trackTimerFired() ) );
|
||||
}
|
||||
@@ -306,11 +305,12 @@ Source::getPlaylistInterface()
|
||||
|
||||
|
||||
void
|
||||
Source::onPlaybackStarted( const Tomahawk::query_ptr& query )
|
||||
Source::onPlaybackStarted( const Tomahawk::query_ptr& query, unsigned int duration )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << query->toString();
|
||||
m_currentTrack = query;
|
||||
m_currentTrackTimer.stop();
|
||||
m_currentTrackTimer.start( duration * 1000 + 900000 ); // duration comes in seconds
|
||||
|
||||
if ( m_playlistInterface.isNull() )
|
||||
getPlaylistInterface();
|
||||
emit playbackStarted( query );
|
||||
|
@@ -122,7 +122,7 @@ private slots:
|
||||
|
||||
void onStateChanged( DBSyncConnection::State newstate, DBSyncConnection::State oldstate, const QString& info );
|
||||
|
||||
void onPlaybackStarted( const Tomahawk::query_ptr& query );
|
||||
void onPlaybackStarted( const Tomahawk::query_ptr& query, unsigned int duration );
|
||||
void onPlaybackFinished( const Tomahawk::query_ptr& query );
|
||||
void trackTimerFired();
|
||||
|
||||
|
@@ -667,7 +667,7 @@ void JabberPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, const
|
||||
Jreen::Capabilities::Ptr caps = presence.payload<Jreen::Capabilities>();
|
||||
if( caps )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: maybe" << "caps " << caps->node() << "requesting disco...";
|
||||
// qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: maybe" << "caps " << caps->node() << "requesting disco...";
|
||||
|
||||
// request disco features
|
||||
QString node = caps->node() + '#' + caps->ver();
|
||||
|
Reference in New Issue
Block a user