mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
* Fixed AudioEngine's now playing data pusher to wait for covers being available.
This commit is contained in:
@@ -345,12 +345,14 @@ void
|
|||||||
AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type )
|
AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type )
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
if ( m_currentTrack->album().isNull() || m_currentTrack->album()->infoLoaded() )
|
if ( m_currentTrack->toQuery()->coverLoaded() )
|
||||||
|
{
|
||||||
onNowPlayingInfoReady( type );
|
onNowPlayingInfoReady( type );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type );
|
NewClosure( m_currentTrack->toQuery().data(), SIGNAL( coverChanged() ), const_cast< AudioEngine* >( this ), SLOT( sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ) ), type );
|
||||||
m_currentTrack->album()->cover( QSize( 0, 0 ), true );
|
m_currentTrack->toQuery()->cover( QSize( 0, 0 ), true );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -359,7 +361,6 @@ AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ty
|
|||||||
void
|
void
|
||||||
AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << type;
|
|
||||||
if ( m_currentTrack.isNull() ||
|
if ( m_currentTrack.isNull() ||
|
||||||
m_currentTrack->track().isNull() ||
|
m_currentTrack->track().isNull() ||
|
||||||
m_currentTrack->artist().isNull() )
|
m_currentTrack->artist().isNull() )
|
||||||
@@ -367,36 +368,35 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
|||||||
|
|
||||||
QVariantMap playInfo;
|
QVariantMap playInfo;
|
||||||
|
|
||||||
if ( !m_currentTrack->album().isNull() )
|
|
||||||
{
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
QImage cover;
|
QImage cover;
|
||||||
cover = m_currentTrack->album()->cover( QSize( 0, 0 ) ).toImage();
|
cover = m_currentTrack->toQuery()->cover( QSize( 0, 0 ) ).toImage();
|
||||||
if ( !cover.isNull() )
|
if ( !cover.isNull() )
|
||||||
{
|
{
|
||||||
playInfo["cover"] = cover;
|
playInfo["cover"] = cover;
|
||||||
|
|
||||||
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) );
|
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) );
|
||||||
if ( !coverTempFile->open() )
|
if ( !coverTempFile->open() )
|
||||||
tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!";
|
{
|
||||||
else
|
tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!";
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
else
|
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;
|
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||||
trackInfo["title"] = m_currentTrack->track();
|
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 );
|
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 );
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -136,6 +136,7 @@ private slots:
|
|||||||
void onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type );
|
void onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type );
|
||||||
void onPlaylistNextTrackReady();
|
void onPlaylistNextTrackReady();
|
||||||
|
|
||||||
|
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
||||||
void sendWaitingNotification() const;
|
void sendWaitingNotification() const;
|
||||||
|
|
||||||
void queueStateSafety();
|
void queueStateSafety();
|
||||||
@@ -149,8 +150,6 @@ private:
|
|||||||
bool isHttpResult( const QString& ) const;
|
bool isHttpResult( const QString& ) const;
|
||||||
bool isLocalResult( const QString& ) const;
|
bool isLocalResult( const QString& ) const;
|
||||||
|
|
||||||
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
|
||||||
|
|
||||||
QSharedPointer<QIODevice> m_input;
|
QSharedPointer<QIODevice> m_input;
|
||||||
|
|
||||||
Tomahawk::query_ptr m_stopAfterTrack;
|
Tomahawk::query_ptr m_stopAfterTrack;
|
||||||
|
Reference in New Issue
Block a user