本文整理汇总了C++中meta::TrackPtr::cachedLyrics方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackPtr::cachedLyrics方法的具体用法?C++ TrackPtr::cachedLyrics怎么用?C++ TrackPtr::cachedLyrics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta::TrackPtr
的用法示例。
在下文中一共展示了TrackPtr::cachedLyrics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTrackMetadataChanged
void LyricsEngine::onTrackMetadataChanged( Meta::TrackPtr track )
{
DEBUG_BLOCK
// Only update if the lyrics have changed.
QString artist = track->artist() ? track->artist()->name() : QString();
if( m_prevLyrics.artist != artist ||
m_prevLyrics.title != track->name() ||
m_prevLyrics.text != track->cachedLyrics() )
update();
}
示例2: update
void LyricsEngine::update()
{
if( m_isUpdateInProgress )
return;
m_isUpdateInProgress = true;
// -- get current title and artist
Meta::TrackPtr currentTrack = The::engineController()->currentTrack();
if( !currentTrack )
{
debug() << "no current track";
m_prevLyrics.clear();
removeAllData( "lyrics" );
setData( "lyrics", "stopped", "stopped" );
m_isUpdateInProgress = false;
return;
}
QString title = currentTrack->name();
QString artist = currentTrack->artist() ? currentTrack->artist()->name() : QString();
// -- clean up title
const QString magnatunePreviewString = QLatin1String( "PREVIEW: buy it at www.magnatune.com" );
if( title.contains(magnatunePreviewString, Qt::CaseSensitive) )
title = title.remove( " (" + magnatunePreviewString + ")" );
if( artist.contains(magnatunePreviewString, Qt::CaseSensitive) )
artist = artist.remove( " (" + magnatunePreviewString + ")" );
if( title.isEmpty() && currentTrack )
{
/* If title is empty, try to use pretty title.
The fact that it often (but not always) has "artist name" together, can be bad,
but at least the user will hopefully get nice suggestions. */
QString prettyTitle = currentTrack->prettyName();
int h = prettyTitle.indexOf( QLatin1Char('-') );
if ( h != -1 )
{
title = prettyTitle.mid( h + 1 ).trimmed();
if( title.contains(magnatunePreviewString, Qt::CaseSensitive) )
title = title.remove( " (" + magnatunePreviewString + ")" );
if( artist.isEmpty() )
{
artist = prettyTitle.mid( 0, h ).trimmed();
if( artist.contains(magnatunePreviewString, Qt::CaseSensitive) )
artist = artist.remove( " (" + magnatunePreviewString + ")" );
}
}
}
LyricsData lyrics = { currentTrack->cachedLyrics(), title, artist, KUrl() };
// Check if the title, the artist and the lyrics are still the same.
if( !lyrics.text.isEmpty() && (lyrics.text == m_prevLyrics.text) )
{
debug() << "nothing changed:" << lyrics.title;
newLyrics( lyrics );
m_isUpdateInProgress = false;
return;
}
// don't rely on caching for streams
const bool cached = !LyricsManager::self()->isEmpty( lyrics.text )
&& !The::engineController()->isStream();
if( cached )
{
newLyrics( lyrics );
}
else
{
// no lyrics, and no lyrics script!
if( !ScriptManager::instance()->lyricsScriptRunning() )
{
debug() << "no lyrics script running";
removeAllData( "lyrics" );
setData( "lyrics", "noscriptrunning", "noscriptrunning" );
disconnect( ScriptManager::instance(), SIGNAL(lyricsScriptStarted()), this, 0 );
connect( ScriptManager::instance(), SIGNAL(lyricsScriptStarted()), SLOT(update()) );
m_isUpdateInProgress = false;
return;
}
// fetch by lyrics script
removeAllData( "lyrics" );
setData( "lyrics", "fetching", "fetching" );
ScriptManager::instance()->notifyFetchLyrics( lyrics.artist, lyrics.title );
}
m_isUpdateInProgress = false;
}