mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 22:56:42 +02:00
Add basic metadata MPRIS info.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "audio/audioengine.h"
|
#include "audio/audioengine.h"
|
||||||
#include "infosystem/infosystemworker.h"
|
#include "infosystem/infosystemworker.h"
|
||||||
|
#include "album.h"
|
||||||
#include "artist.h"
|
#include "artist.h"
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
@@ -149,7 +150,7 @@ MprisPlugin::canPlay() const
|
|||||||
bool
|
bool
|
||||||
MprisPlugin::canSeek() const
|
MprisPlugin::canSeek() const
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@@ -201,7 +202,18 @@ MprisPlugin::maximumRate() const
|
|||||||
QVariantMap
|
QVariantMap
|
||||||
MprisPlugin::metadata() const
|
MprisPlugin::metadata() const
|
||||||
{
|
{
|
||||||
return QVariantMap();
|
QVariantMap metadataMap;
|
||||||
|
Tomahawk::result_ptr track = AudioEngine::instance()->currentTrack();
|
||||||
|
if( track )
|
||||||
|
{
|
||||||
|
metadataMap.insert( "mpris:trackid", track->id() );
|
||||||
|
metadataMap.insert( "mpris:length", track->duration() );
|
||||||
|
metadataMap.insert( "xesam:album", track->album()->name() );
|
||||||
|
metadataMap.insert( "xesam:artist", track->artist()->name() );
|
||||||
|
metadataMap.insert( "xesam:title", track->track() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
@@ -278,9 +290,12 @@ MprisPlugin::Next()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::OpenUri(const QString &Uri)
|
MprisPlugin::OpenUri( const QString &Uri )
|
||||||
{
|
{
|
||||||
// TODO
|
if( Uri.contains( "tomahawk://" ) )
|
||||||
|
GlobalActionManager::instance()->parseTomahawkLink( Uri );
|
||||||
|
else if( Uri.contains( "spotify:" ) )
|
||||||
|
GlobalActionManager::instance()->openSpotifyLink( Uri );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -310,7 +325,10 @@ MprisPlugin::Previous()
|
|||||||
void
|
void
|
||||||
MprisPlugin::Seek( qlonglong Offset )
|
MprisPlugin::Seek( qlonglong Offset )
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
/*
|
||||||
qlonglong seekTime = position() + Offset;
|
qlonglong seekTime = position() + Offset;
|
||||||
|
qDebug() << "seekTime: " << seekTime;
|
||||||
if( seekTime < 0 )
|
if( seekTime < 0 )
|
||||||
AudioEngine::instance()->seek( 0 );
|
AudioEngine::instance()->seek( 0 );
|
||||||
else if( seekTime > AudioEngine::instance()->currentTrackTotalTime() )
|
else if( seekTime > AudioEngine::instance()->currentTrackTotalTime() )
|
||||||
@@ -318,8 +336,7 @@ MprisPlugin::Seek( qlonglong Offset )
|
|||||||
// seekTime is in microseconds, but we work internally in milliseconds
|
// seekTime is in microseconds, but we work internally in milliseconds
|
||||||
else
|
else
|
||||||
AudioEngine::instance()->seek( (qint64) ( seekTime / 1000 ) );
|
AudioEngine::instance()->seek( (qint64) ( seekTime / 1000 ) );
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -185,12 +185,14 @@ void MprisPluginPlayerAdaptor::Previous()
|
|||||||
|
|
||||||
void MprisPluginPlayerAdaptor::Seek(qlonglong Offset)
|
void MprisPluginPlayerAdaptor::Seek(qlonglong Offset)
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
// handle method call org.mpris.MediaPlayer2.Player.Seek
|
// handle method call org.mpris.MediaPlayer2.Player.Seek
|
||||||
QMetaObject::invokeMethod(parent(), "Seek", Q_ARG(qlonglong, Offset));
|
QMetaObject::invokeMethod(parent(), "Seek", Q_ARG(qlonglong, Offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MprisPluginPlayerAdaptor::SetPosition(const QDBusObjectPath &TrackId, qlonglong Position)
|
void MprisPluginPlayerAdaptor::SetPosition(const QDBusObjectPath &TrackId, qlonglong Position)
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
// handle method call org.mpris.MediaPlayer2.Player.SetPosition
|
// handle method call org.mpris.MediaPlayer2.Player.SetPosition
|
||||||
QMetaObject::invokeMethod(parent(), "SetPosition", Q_ARG(QDBusObjectPath, TrackId), Q_ARG(qlonglong, Position));
|
QMetaObject::invokeMethod(parent(), "SetPosition", Q_ARG(QDBusObjectPath, TrackId), Q_ARG(qlonglong, Position));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user