Ejemplo n.º 1
0
void MediaPlayer2Player::updatePlaying( bool play, const QString &title, const QString &artist, const QString &album, int length, bool )
{
	bool tmp = play && length > 0;
	if ( tmp != can_seek )
		propertyChanged( "CanSeek", can_seek = tmp );
	if ( !play )
		clearMetaData();
	else
	{
		m_data[ "mpris:length" ] = len = length * 1000000LL;
		m_data[ "xesam:title" ] = title;
		m_data[ "xesam:artist" ] = artist;
		m_data[ "xesam:album" ] = album;
	}
	propertyChanged( "Metadata", m_data );
}
Ejemplo n.º 2
0
MediaPlayer2Player::MediaPlayer2Player( QObject *p ) :
	QDBusAbstractAdaptor( p ),
	exportCovers( false ), removeCover( false ),
	trackID( QDBusObjectPath( QString( "/org/qmplay2/MediaPlayer2/Track/%1" ).arg( qrand() ) ) ), //is it OK?
	playState( "Stopped" ),
	can_seek( false ),
	vol( 1.0 ), r( 1.0 ),
	len( 0 ), pos( 0 )
{
	clearMetaData();
	m_data[ "mpris:trackid" ] = QVariant::fromValue< QDBusObjectPath >( trackID );
	connect( &QMPlay2Core, SIGNAL( updatePlaying( bool, const QString &, const QString &, const QString &, int, bool ) ), this, SLOT( updatePlaying( bool, const QString &, const QString &, const QString &, int, bool ) ) );
	connect( &QMPlay2Core, SIGNAL( coverDataFromMediaFile( const QByteArray & ) ), this, SLOT( coverDataFromMediaFile( const QByteArray & ) ) );
	connect( &QMPlay2Core, SIGNAL( playStateChanged( const QString & ) ), this, SLOT( playStateChanged( const QString & ) ) );
	connect( &QMPlay2Core, SIGNAL( coverFile( const QString & ) ), this, SLOT( coverFile( const QString & ) ) );
	connect( &QMPlay2Core, SIGNAL( speedChanged( double ) ), this, SLOT( speedChanged( double ) ) );
	connect( &QMPlay2Core, SIGNAL( volumeChanged( double ) ), this, SLOT( volumeChanged( double ) ) );
	connect( &QMPlay2Core, SIGNAL( posChanged( int ) ), this, SLOT( posChanged( int ) ) );
	connect( &QMPlay2Core, SIGNAL( seeked( int ) ), this, SLOT( seeked( int ) ) );
}
Ejemplo n.º 3
0
void MediaPlayer2Player::updatePlaying(bool play, const QString &title, const QString &artist, const QString &album, int length, bool needCover, const QString &fileName)
{
	Q_UNUSED(needCover)
	const bool tmp = play && length > 0;
	if (tmp != can_seek)
		propertyChanged("CanSeek", can_seek = tmp);
	if (!play)
		clearMetaData();
	else
	{
		m_data["mpris:length"] = length < 0 ? -1 : length * 1000000LL;
		if (title.isEmpty() && artist.isEmpty())
			m_data["xesam:title"] = fileName;
		else
		{
			m_data["xesam:title"] = title;
			m_data["xesam:artist"] = QStringList{artist};
		}
		m_data["xesam:album"] = album;
	}
	propertyChanged("Metadata", m_data);
}