Пример #1
0
void MediaPlayer2Player::tick(qint64 newPos)
{
    if (newPos - oldPos > Dragon::engine()->tickInterval() + 250 || newPos < oldPos)
        emit Seeked(newPos * 1000);

    oldPos = newPos;
}
Пример #2
0
PlayerContainer::PlayerContainer(const QString& busAddress, QObject* parent)
    : DataContainer(parent)
    , m_caps(NoCaps)
    , m_fetchesPending(0)
    , m_dbusAddress(busAddress)
    , m_currentRate(0.0)
{
    Q_ASSERT(!busAddress.isEmpty());
    Q_ASSERT(busAddress.startsWith(QLatin1String("org.mpris.MediaPlayer2.")));

    m_propsIface = new OrgFreedesktopDBusPropertiesInterface(
            busAddress, MPRIS2_PATH,
            QDBusConnection::sessionBus(), this);

    m_playerIface = new OrgMprisMediaPlayer2PlayerInterface(
            busAddress, MPRIS2_PATH,
            QDBusConnection::sessionBus(), this);

    m_rootIface = new OrgMprisMediaPlayer2Interface(
            busAddress, MPRIS2_PATH,
            QDBusConnection::sessionBus(), this);

    connect(m_propsIface, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
            this,         SLOT(propertiesChanged(QString,QVariantMap,QStringList)));

    connect(m_playerIface, SIGNAL(Seeked(qlonglong)),
            this,          SLOT(seeked(qlonglong)));

    refresh();
}
Пример #3
0
Player::Player(QObject *parent): QDBusAbstractAdaptor(parent), d(new Data) {
    d->mw = cApp.mainWindow();
    d->engine = d->mw->engine();
    d->playlist = d->mw->playlist();

    d->playbackStatus = d->toDBus(d->engine->state());
    d->volume = d->engine->volume();
    d->metaData = d->toDBus(d->engine->metaData());
    connect(d->engine, &PlayEngine::metaDataChanged, this, [this] () {
        d->metaData = d->toDBus(d->engine->metaData());
        sendPropertiesChanged(this, "Metadata", d->metaData);
    });
    connect(d->engine, &PlayEngine::stateChanged, this, [this] (PlayEngine::State state) {
        d->playbackStatus = d->toDBus(d->engine->state());
        QVariantMap map;
        map["PlaybackStatus"] = d->playbackStatus;
        map["CanPause"] = map["CanPlay"] = state != PlayEngine::Error;
        sendPropertiesChanged(this, map);
    });
    connect(d->engine, &PlayEngine::speedChanged, this, [this] (double speed) {
        sendPropertiesChanged(this, "Rate", speed);
    });
    auto checkNextPrevious = [this] () {
        QVariantMap map;
        map["CanGoNext"] = d->playlist->hasNext();
        map["CanGoPrevious"] = d->playlist->hasPrevious();
        sendPropertiesChanged(this, map);
    };
    connect(d->playlist, &PlaylistModel::loadedChanged, this, checkNextPrevious);
    connect(d->engine, &PlayEngine::seekableChanged, this, [this] (bool seekable) {
        sendPropertiesChanged(this, "CanSeek", seekable);
    });
    connect(d->engine, &PlayEngine::sought, this, [this] () { emit Seeked(time()); });
}
Пример #4
0
Remote::Remote(Player* player, QObject* parent)
  : QObject(parent),
    player_(player),
    connection_(new xrme::Connection(this)),
    retry_count_(0)
{
  connection_->SetMediaPlayer(this);
  connection_->SetMediaStorage(this);
  connection_->set_verbose(true);
  connect(connection_, SIGNAL(Connected()), SLOT(Connected()));
  connect(connection_, SIGNAL(Disconnected(QString)), SLOT(Disconnected(QString)));

  connect(player_, SIGNAL(Playing()), SLOT(SetStateChanged()));
  connect(player_, SIGNAL(Paused()), SLOT(SetStateChanged()));
  connect(player_, SIGNAL(Stopped()), SLOT(SetStateChanged()));
  connect(player_, SIGNAL(PlaylistFinished()), SLOT(SetStateChanged()));
  connect(player_, SIGNAL(VolumeChanged(int)), SLOT(SetStateChanged()));
  connect(player_, SIGNAL(Seeked(qlonglong)), SLOT(SetStateChanged()));
  connect(player_->playlists(), SIGNAL(CurrentSongChanged(Song)), SLOT(SetStateChanged()));

  connect(connection_,
      SIGNAL(TomahawkSIPReceived(const QVariant&)),
      SLOT(TomahawkSIPReceived(const QVariant&)));

  ReloadSettings();
}
void MprisControlPlugin::addPlayer(const QString& service)
{
    QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2");
    //FIXME: This call hangs and returns an empty string if KDED is still starting!
    const QString identity = mprisInterface.property("Identity").toString();
    playerList[identity] = service;
    qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris addPlayer" << service << "->" << identity;
    sendPlayerList();

    OrgFreedesktopDBusPropertiesInterface* freedesktopInterface = new OrgFreedesktopDBusPropertiesInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), this);
    connect(freedesktopInterface, SIGNAL(PropertiesChanged(QString, QVariantMap, QStringList)), this, SLOT(propertiesChanged(QString, QVariantMap)));

    OrgMprisMediaPlayer2PlayerInterface* mprisInterface0  = new OrgMprisMediaPlayer2PlayerInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
    connect(mprisInterface0, SIGNAL(Seeked(qlonglong)), this, SLOT(seeked(qlonglong)));
}
Пример #6
0
void Mpris2::SetPosition(const QDBusObjectPath& trackId, qlonglong position)
{
    const SongInfo& si = m_trayicon->m_playlist.at(m_trayicon->m_playIndex);
    QString currentTrackId = "/org/mpris/MediaPlayer2/Track/" + QString::number(si.sid);

    if (trackId.path() != currentTrackId)
        return;

    if (m_trayicon->m_playIndex == -1)
        return;

    if (position < 0 || position > si.length * 1000 * 1000)
        return;

    m_trayicon->m_media->seek(position / 1000);

    /// FIXME: make this async
    emit Seeked(position);
}
Пример #7
0
void Mpris2::Seek(qlonglong offset)
{
    qlonglong position = Position() + offset;

    if (position < 0)
        position = 0;

    if (m_trayicon->m_playIndex == -1)
        return;

    const SongInfo& si = m_trayicon->m_playlist.at(m_trayicon->m_playIndex);
    if (position > si.length * 1000 * 1000)
        Next();

    m_trayicon->m_media->seek(position / 1000);

    /// FIXME: make this async
    emit Seeked(position);
}
Пример #8
0
void MediaPlayer2Player::seeked(int newPos) const
{
    // casts int to uint64
    emit Seeked(newPos);
}
Пример #9
0
void MediaPlayer2Player::seeked( int pos )
{
	emit Seeked( pos * 1000000LL );
}
Пример #10
0
 void Mpris2DBusHandler::trackPositionChanged( qint64 position, bool seeked )
 {
     if( seeked )
         Seeked( position * 1000 );
 }