Changeset View
Changeset View
Standalone View
Standalone View
host/mprisplugin.cpp
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | |||||
124 | void MPrisPlugin::handleData(const QString &event, const QJsonObject &data) | 124 | void MPrisPlugin::handleData(const QString &event, const QJsonObject &data) | ||
125 | { | 125 | { | ||
126 | if (event == QLatin1String("gone")) { | 126 | if (event == QLatin1String("gone")) { | ||
127 | unregisterService(); | 127 | unregisterService(); | ||
128 | setPlaybackStatus(QStringLiteral("Stopped")); // just in case | 128 | setPlaybackStatus(QStringLiteral("Stopped")); // just in case | ||
129 | m_canGoNext = false; | 129 | m_canGoNext = false; | ||
130 | m_canGoPrevious = false; | 130 | m_canGoPrevious = false; | ||
131 | m_pageTitle.clear(); | 131 | m_pageTitle.clear(); | ||
132 | m_tabTitle.clear(); | ||||
132 | m_url.clear(); | 133 | m_url.clear(); | ||
133 | m_mediaSrc.clear(); | 134 | m_mediaSrc.clear(); | ||
134 | m_title.clear(); | 135 | m_title.clear(); | ||
135 | m_artist.clear(); | 136 | m_artist.clear(); | ||
136 | m_artworkUrl.clear(); | 137 | m_artworkUrl.clear(); | ||
137 | m_volume = 1.0; | 138 | m_volume = 1.0; | ||
138 | m_muted = false; | 139 | m_muted = false; | ||
139 | m_length = 0; | 140 | m_length = 0; | ||
140 | m_position = 0; | 141 | m_position = 0; | ||
141 | } else if (event == QLatin1String("playing")) { | 142 | } else if (event == QLatin1String("playing")) { | ||
142 | setPlaybackStatus(QStringLiteral("Playing")); | 143 | setPlaybackStatus(QStringLiteral("Playing")); | ||
143 | m_pageTitle = data.value(QStringLiteral("tabTitle")).toString(); | 144 | | ||
145 | m_pageTitle = data.value(QStringLiteral("pageTitle")).toString(); | ||||
146 | m_tabTitle = data.value(QStringLiteral("tabTitle")).toString(); | ||||
147 | | ||||
144 | m_url = QUrl(data.value(QStringLiteral("url")).toString()); | 148 | m_url = QUrl(data.value(QStringLiteral("url")).toString()); | ||
145 | m_mediaSrc = QUrl(data.value(QStringLiteral("mediaSrc")).toString()); | 149 | m_mediaSrc = QUrl(data.value(QStringLiteral("mediaSrc")).toString()); | ||
146 | 150 | | |||
147 | const qreal oldVolume = volume(); | 151 | const qreal oldVolume = volume(); | ||
148 | 152 | | |||
149 | m_volume = data.value(QStringLiteral("volume")).toDouble(1); | 153 | m_volume = data.value(QStringLiteral("volume")).toDouble(1); | ||
150 | m_muted = data.value(QStringLiteral("muted")).toBool(); | 154 | m_muted = data.value(QStringLiteral("muted")).toBool(); | ||
151 | 155 | | |||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 365 | { | |||
371 | emitPropertyChange(m_player, "LoopStatus"); | 375 | emitPropertyChange(m_player, "LoopStatus"); | ||
372 | } | 376 | } | ||
373 | 377 | | |||
374 | QString MPrisPlugin::effectiveTitle() const | 378 | QString MPrisPlugin::effectiveTitle() const | ||
375 | { | 379 | { | ||
376 | if (!m_title.isEmpty()) { | 380 | if (!m_title.isEmpty()) { | ||
377 | return m_title; | 381 | return m_title; | ||
378 | } | 382 | } | ||
383 | if (!m_pageTitle.isEmpty()) { | ||||
379 | return m_pageTitle; | 384 | return m_pageTitle; | ||
380 | } | 385 | } | ||
386 | return m_tabTitle; | ||||
387 | } | ||||
381 | 388 | | |||
382 | QVariantMap MPrisPlugin::metadata() const | 389 | QVariantMap MPrisPlugin::metadata() const | ||
383 | { | 390 | { | ||
384 | QVariantMap metadata; | 391 | QVariantMap metadata; | ||
385 | 392 | | |||
386 | // HACK this is needed or else SetPosition won't do anything | 393 | // HACK this is needed or else SetPosition won't do anything | ||
387 | // TODO use something more sensible, e.g. at least have the tab id with the player in there or so | 394 | // TODO use something more sensible, e.g. at least have the tab id with the player in there or so | ||
388 | metadata.insert(QStringLiteral("mpris:trackid"), QVariant::fromValue(QDBusObjectPath(QStringLiteral("/org/kde/plasma/browser_integration/1337")))); | 395 | metadata.insert(QStringLiteral("mpris:trackid"), QVariant::fromValue(QDBusObjectPath(QStringLiteral("/org/kde/plasma/browser_integration/1337")))); | ||
▲ Show 20 Lines • Show All 212 Lines • Show Last 20 Lines |