/** * Called when the signal is received. */ void Scrobbler::engineNewMetaData( const MetaBundle& bundle, bool trackChanged ) { //debug() << "engineNewMetaData: " << bundle.artist() << ":" << bundle.album() << ":" << bundle.title() << ":" << trackChanged << endl; if ( !trackChanged ) { debug() << "It's still the same track." << endl; m_item->setArtist( bundle.artist() ); m_item->setAlbum( bundle.album() ); m_item->setTitle( bundle.title() ); return; } //to work around xine bug, we have to explictly prevent submission the first few seconds of a track //http://sourceforge.net/tracker/index.php?func=detail&aid=1401026&group_id=9655&atid=109655 m_timer.stop(); m_timer.start( 10000, true ); m_startPos = 0; // Plugins must not submit tracks played from online radio stations, even // if they appear to be providing correct metadata. if ( !bundle.streamUrl().isEmpty() ) { debug() << "Won't submit: It's a stream." << endl; m_validForSending = false; } else if( bundle.podcastBundle() != NULL ) { debug() << "Won't submit: It's a podcast." << endl; m_validForSending = false; } else { *m_item = SubmitItem( bundle.artist(), bundle.album(), bundle.title(), bundle.length() ); m_validForSending = true; // check length etc later } }
void amaroK::TrayIcon::engineNewMetaData( const MetaBundle &bundle, bool /*trackChanged*/ ) { trackLength = bundle.length() * 1000; }
void TrackToolTip::setTrack( const MetaBundle &tags, bool force ) { if( force || m_tags != tags || m_tags.url() != tags.url() ) { m_haspos = false; m_tooltip = QString::null; QStringList left, right; const QString tableRow = "<tr><td width=70 align=right>%1:</td><td align=left>%2</td></tr>"; QString filename = "", title = ""; //special case these, put the first one encountered on top Playlist *playlist = Playlist::instance(); const int n = playlist->numVisibleColumns(); for( int i = 0; i < n; ++i ) { const int column = playlist->mapToLogicalColumn( i ); if( column == PlaylistItem::Score ) { const int score = CollectionDB::instance()->getSongPercentage( tags.url().path() ); if( score > 0 ) { right << QString::number( score ); left << playlist->columnText( column ); } } else if( column == PlaylistItem::Rating ) { const int rating = CollectionDB::instance()->getSongRating( tags.url().path() ); if( rating > 0 ) { QString s; for( int i = 0; i < rating / 2; ++i ) s += QString( "<img src=\"%1\" height=\"%2\" width=\"%3\">" ) .arg( locate( "data", "amarok/images/star.png" ) ) .arg( QFontMetrics( QToolTip::font() ).height() ) .arg( QFontMetrics( QToolTip::font() ).height() ); if( rating % 2 ) s += QString( "<img src=\"%1\" height=\"%2\" width=\"%3\">" ) .arg( locate( "data", "amarok/images/smallstar.png" ) ) .arg( QFontMetrics( QToolTip::font() ).height() ) .arg( QFontMetrics( QToolTip::font() ).height() ); right << s; left << playlist->columnText( column ); } } else if( column == PlaylistItem::PlayCount ) { const int count = CollectionDB::instance()->getPlayCount( tags.url().path() ); if( count > 0 ) { right << QString::number( count ); left << playlist->columnText( column ); } } else if( column == PlaylistItem::LastPlayed ) { const uint lastPlayed = CollectionDB::instance()->getLastPlay( tags.url().path() ).toTime_t(); right << amaroK::verboseTimeSince( lastPlayed ); left << playlist->columnText( column ); } else if( column == PlaylistItem::Filename && title.isEmpty() ) filename = tags.prettyText( column ); else if( column == PlaylistItem::Title && filename.isEmpty() ) title = tags.prettyText( column ); else if( column != PlaylistItem::Length ) { const QString tag = tags.prettyText( column ); if( !tag.isEmpty() ) { right << tag; left << playlist->columnText( column ); } } } if( !filename.isEmpty() ) { right.prepend( filename ); left.prepend( playlist->columnText( PlaylistItem::Filename ) ); } else if( !title.isEmpty() ) { right.prepend( title ); left.prepend( playlist->columnText( PlaylistItem::Title ) ); } if( tags.length() > 0 ) //special case this too, always on the bottom { m_haspos = true; right << "%9 / " + tags.prettyLength(); left << playlist->columnText( PlaylistItem::Length ); } //NOTE it seems to be necessary to <center> each element indivdually m_tooltip += "<center><b>Amarok</b></center><table cellpadding='2' cellspacing='2' align='center'><tr>"; m_tooltip += "%1"; //the cover gets substituted in, in tooltip() m_cover = CollectionDB::instance()->podcastImage( tags ); if( m_cover.isEmpty() || m_cover.contains( "nocover" ) != -1 ) { m_cover = CollectionDB::instance()->albumImage( tags ); if ( m_cover == CollectionDB::instance()->notAvailCover() ) m_cover = QString::null; } m_tooltip += "<td><table cellpadding='0' cellspacing='0'>"; if (tags.title().isEmpty() || tags.artist().isEmpty()) // no title or no artist, so we add prettyTitle m_tooltip += QString ("<tr><td align=center colspan='2'>%1</td></tr>") .arg(tags.veryNiceTitle()); for( uint x = 0; x < left.count(); ++x ) if ( !right[x].isEmpty() ) m_tooltip += tableRow.arg( left[x] ).arg( right[x] ); m_tooltip += "</table></td>"; m_tooltip += "</tr></table></center>"; m_tags = tags; updateWidgets(); } }