mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-22 08:49:42 +01:00
* Fixed AudioEngine's now playing data pusher to wait for covers being available.
This commit is contained in:
parent
f24d11b41a
commit
b811b12e77
src/libtomahawk/audio
@ -345,12 +345,14 @@ void
|
||||
AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type )
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
if ( m_currentTrack->album().isNull() || m_currentTrack->album()->infoLoaded() )
|
||||
if ( m_currentTrack->toQuery()->coverLoaded() )
|
||||
{
|
||||
onNowPlayingInfoReady( type );
|
||||
}
|
||||
else
|
||||
{
|
||||
NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type );
|
||||
m_currentTrack->album()->cover( QSize( 0, 0 ), true );
|
||||
NewClosure( m_currentTrack->toQuery().data(), SIGNAL( coverChanged() ), const_cast< AudioEngine* >( this ), SLOT( sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ) ), type );
|
||||
m_currentTrack->toQuery()->cover( QSize( 0, 0 ), true );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -359,7 +361,6 @@ AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ty
|
||||
void
|
||||
AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << type;
|
||||
if ( m_currentTrack.isNull() ||
|
||||
m_currentTrack->track().isNull() ||
|
||||
m_currentTrack->artist().isNull() )
|
||||
@ -367,36 +368,35 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
||||
|
||||
QVariantMap playInfo;
|
||||
|
||||
if ( !m_currentTrack->album().isNull() )
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QImage cover;
|
||||
cover = m_currentTrack->album()->cover( QSize( 0, 0 ) ).toImage();
|
||||
if ( !cover.isNull() )
|
||||
{
|
||||
playInfo["cover"] = cover;
|
||||
QImage cover;
|
||||
cover = m_currentTrack->toQuery()->cover( QSize( 0, 0 ) ).toImage();
|
||||
if ( !cover.isNull() )
|
||||
{
|
||||
playInfo["cover"] = cover;
|
||||
|
||||
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) );
|
||||
if ( !coverTempFile->open() )
|
||||
tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!";
|
||||
else
|
||||
{
|
||||
// Finally, save the image to the new temp file
|
||||
coverTempFile->setAutoRemove( false );
|
||||
if ( cover.save( coverTempFile, "PNG" ) )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *coverTempFile ).absoluteFilePath();
|
||||
playInfo["coveruri"] = QFileInfo( *coverTempFile ).absoluteFilePath();
|
||||
}
|
||||
else
|
||||
tDebug() << Q_FUNC_INFO << "failed to save cover image!";
|
||||
}
|
||||
delete coverTempFile;
|
||||
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) );
|
||||
if ( !coverTempFile->open() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!";
|
||||
}
|
||||
else
|
||||
tDebug() << Q_FUNC_INFO << "Cover from album is null!";
|
||||
#endif
|
||||
{
|
||||
// Finally, save the image to the new temp file
|
||||
coverTempFile->setAutoRemove( false );
|
||||
if ( cover.save( coverTempFile, "PNG" ) )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *coverTempFile ).absoluteFilePath();
|
||||
playInfo["coveruri"] = QFileInfo( *coverTempFile ).absoluteFilePath();
|
||||
}
|
||||
else
|
||||
tDebug() << Q_FUNC_INFO << "failed to save cover image!";
|
||||
}
|
||||
delete coverTempFile;
|
||||
}
|
||||
else
|
||||
tDebug() << Q_FUNC_INFO << "Cover from query is null!";
|
||||
#endif
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["title"] = m_currentTrack->track();
|
||||
@ -410,7 +410,7 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
||||
|
||||
Tomahawk::InfoSystem::InfoPushData pushData ( s_aeInfoIdentifier, type, playInfo, Tomahawk::InfoSystem::PushShortUrlFlag );
|
||||
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "pushing data with type " << type;
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "pushing data with type" << type;
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,7 @@ private slots:
|
||||
void onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type );
|
||||
void onPlaylistNextTrackReady();
|
||||
|
||||
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
||||
void sendWaitingNotification() const;
|
||||
|
||||
void queueStateSafety();
|
||||
@ -149,8 +150,6 @@ private:
|
||||
bool isHttpResult( const QString& ) const;
|
||||
bool isLocalResult( const QString& ) const;
|
||||
|
||||
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
||||
|
||||
QSharedPointer<QIODevice> m_input;
|
||||
|
||||
Tomahawk::query_ptr m_stopAfterTrack;
|
||||
|
Loading…
x
Reference in New Issue
Block a user