diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index ed4cef2cc..d6ce14f77 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -23,6 +23,7 @@ #include "config.h" +#include "filemetadata/MusicScanner.h" #include "jobview/JobStatusView.h" #include "jobview/JobStatusModel.h" #include "jobview/ErrorStatusMessage.h" @@ -36,6 +37,7 @@ #include "Artist.h" #include "Pipeline.h" #include "PlaylistEntry.h" +#include "SourceList.h" #include "TomahawkSettings.h" #include "UrlHandler.h" @@ -193,7 +195,6 @@ AudioEnginePrivate::onAudioDataArrived( QMap( trackInfo ); playInfo["private"] = TomahawkSettings::instance()->privateListeningMode(); - Tomahawk::InfoSystem::InfoPushData pushData ( s_aeInfoIdentifier, type, playInfo, Tomahawk::InfoSystem::PushShortUrlFlag ); + Tomahawk::InfoSystem::InfoPushData pushData( s_aeInfoIdentifier, type, playInfo, Tomahawk::InfoSystem::PushShortUrlFlag ); Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData ); } @@ -929,6 +930,41 @@ AudioEngine::loadNextTrack() } +void +AudioEngine::play( const QUrl& url ) +{ + tDebug() << Q_FUNC_INFO << url; + + result_ptr result = Result::get( url.toString() ); + const QVariantMap tags = MusicScanner::readTags( QFileInfo( url.toLocalFile() ) ).toMap(); + + track_ptr t; + if ( !tags.isEmpty() ) + { + t = Track::get( tags["artist"].toString(), tags["track"].toString(), tags["album"].toString(), + tags["duration"].toInt(), tags["composer"].toString(), + tags["albumpos"].toUInt(), tags["discnumber"].toUInt() ); + + result->setSize( tags["size"].toUInt() ); + result->setBitrate( tags["bitrate"].toUInt() ); + result->setModificationTime( tags["mtime"].toUInt() ); + result->setMimetype( tags["mimetype"].toString() ); + } + else + { + t = Tomahawk::Track::get( "Unknown Artist", "Unknown Track" ); + } + + + result->setTrack( t ); + result->setScore( 1.0 ); + result->setCollection( SourceList::instance()->getLocal()->collections().first(), false ); + + // Tomahawk::query_ptr qry = Tomahawk::Query::get( t ); + playItem( playlistinterface_ptr(), result, query_ptr() ); +} + + void AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result, const Tomahawk::query_ptr& fromQuery ) { diff --git a/src/libtomahawk/audio/AudioEngine.h b/src/libtomahawk/audio/AudioEngine.h index 1b9e60b43..d8363334e 100644 --- a/src/libtomahawk/audio/AudioEngine.h +++ b/src/libtomahawk/audio/AudioEngine.h @@ -136,6 +136,7 @@ public slots: void mute(); void toggleMute(); + void play( const QUrl& url ); void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result, const Tomahawk::query_ptr& fromQuery = Tomahawk::query_ptr() ); void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::query_ptr& query ); void playItem( const Tomahawk::artist_ptr& artist );