Changeset View
Changeset View
Standalone View
Standalone View
host/mprisplugin.cpp
Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 126 | if (event == QLatin1String("gone")) { | |||
---|---|---|---|---|---|
130 | m_canGoPrevious = false; | 130 | m_canGoPrevious = false; | ||
131 | m_pageTitle.clear(); | 131 | m_pageTitle.clear(); | ||
132 | m_url.clear(); | 132 | m_url.clear(); | ||
133 | m_mediaSrc.clear(); | 133 | m_mediaSrc.clear(); | ||
134 | m_title.clear(); | 134 | m_title.clear(); | ||
135 | m_artist.clear(); | 135 | m_artist.clear(); | ||
136 | m_artworkUrl.clear(); | 136 | m_artworkUrl.clear(); | ||
137 | m_volume = 1.0; | 137 | m_volume = 1.0; | ||
138 | m_muted = false; | ||||
138 | m_length = 0; | 139 | m_length = 0; | ||
139 | m_position = 0; | 140 | m_position = 0; | ||
140 | } else if (event == QLatin1String("playing")) { | 141 | } else if (event == QLatin1String("playing")) { | ||
141 | setPlaybackStatus(QStringLiteral("Playing")); | 142 | setPlaybackStatus(QStringLiteral("Playing")); | ||
142 | m_pageTitle = data.value(QStringLiteral("tabTitle")).toString(); | 143 | m_pageTitle = data.value(QStringLiteral("tabTitle")).toString(); | ||
143 | m_url = QUrl(data.value(QStringLiteral("url")).toString()); | 144 | m_url = QUrl(data.value(QStringLiteral("url")).toString()); | ||
144 | m_mediaSrc = QUrl(data.value(QStringLiteral("mediaSrc")).toString()); | 145 | m_mediaSrc = QUrl(data.value(QStringLiteral("mediaSrc")).toString()); | ||
145 | 146 | | |||
146 | const qreal volume = data.value(QStringLiteral("volume")).toDouble(1); | 147 | const qreal oldVolume = volume(); | ||
147 | if (m_volume != volume) { | 148 | | ||
148 | m_volume = volume; | 149 | m_volume = data.value(QStringLiteral("volume")).toDouble(1); | ||
150 | m_muted = data.value(QStringLiteral("muted")).toBool(); | ||||
151 | | ||||
152 | if (volume() != oldVolume) { | ||||
149 | emitPropertyChange(m_player, "Volume"); | 153 | emitPropertyChange(m_player, "Volume"); | ||
150 | } | 154 | } | ||
151 | 155 | | |||
152 | const qreal length = data.value(QStringLiteral("duration")).toDouble(); | 156 | const qreal length = data.value(QStringLiteral("duration")).toDouble(); | ||
153 | // <video> duration is in seconds, mpris uses microseconds | 157 | // <video> duration is in seconds, mpris uses microseconds | ||
154 | setLength(length * 1000 * 1000); | 158 | setLength(length * 1000 * 1000); | ||
155 | 159 | | |||
156 | const qreal position = data.value(QStringLiteral("currentTime")).toDouble(); | 160 | const qreal position = data.value(QStringLiteral("currentTime")).toDouble(); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 205 | } else if (event == QLatin1String("ratechange")) { | |||
203 | emitPropertyChange(m_player, "Rate"); | 207 | emitPropertyChange(m_player, "Rate"); | ||
204 | } else if (event == QLatin1String("seeking") || event == QLatin1String("seeked")) { | 208 | } else if (event == QLatin1String("seeking") || event == QLatin1String("seeked")) { | ||
205 | // seeked is explicit user interaction, signal a change on dbus | 209 | // seeked is explicit user interaction, signal a change on dbus | ||
206 | const qreal position = data.value(QStringLiteral("currentTime")).toDouble(); | 210 | const qreal position = data.value(QStringLiteral("currentTime")).toDouble(); | ||
207 | // FIXME actually invoke "Seeked" signal | 211 | // FIXME actually invoke "Seeked" signal | ||
208 | setPosition(position * 1000 * 1000); | 212 | setPosition(position * 1000 * 1000); | ||
209 | } else if (event == QLatin1String("volumechange")) { | 213 | } else if (event == QLatin1String("volumechange")) { | ||
210 | m_volume = data.value(QStringLiteral("volume")).toDouble(1); | 214 | m_volume = data.value(QStringLiteral("volume")).toDouble(1); | ||
215 | m_muted = data.value(QStringLiteral("muted")).toBool(); | ||||
211 | emitPropertyChange(m_player, "Volume"); | 216 | emitPropertyChange(m_player, "Volume"); | ||
212 | } else if (event == QLatin1String("metadata")) { | 217 | } else if (event == QLatin1String("metadata")) { | ||
213 | processMetadata(data.value(QStringLiteral("metadata")).toObject()); | 218 | processMetadata(data.value(QStringLiteral("metadata")).toObject()); | ||
214 | } else if (event == QLatin1String("callbacks")) { | 219 | } else if (event == QLatin1String("callbacks")) { | ||
215 | processCallbacks(data.value(QStringLiteral("callbacks")).toArray()); | 220 | processCallbacks(data.value(QStringLiteral("callbacks")).toArray()); | ||
216 | } else if (event == QLatin1String("titlechange")) { | 221 | } else if (event == QLatin1String("titlechange")) { | ||
217 | const QString oldTitle = effectiveTitle(); | 222 | const QString oldTitle = effectiveTitle(); | ||
218 | m_pageTitle = data.value(QStringLiteral("pageTitle")).toString(); | 223 | m_pageTitle = data.value(QStringLiteral("pageTitle")).toString(); | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | |||||
289 | bool MPrisPlugin::canSeek() const | 294 | bool MPrisPlugin::canSeek() const | ||
290 | { | 295 | { | ||
291 | // TODO use player.seekable for determining whether we can seek? | 296 | // TODO use player.seekable for determining whether we can seek? | ||
292 | return m_length > 0; | 297 | return m_length > 0; | ||
293 | } | 298 | } | ||
294 | 299 | | |||
295 | qreal MPrisPlugin::volume() const | 300 | qreal MPrisPlugin::volume() const | ||
296 | { | 301 | { | ||
302 | if (m_muted) { | ||||
303 | return 0.0; | ||||
304 | } | ||||
297 | return m_volume; | 305 | return m_volume; | ||
298 | } | 306 | } | ||
299 | 307 | | |||
300 | void MPrisPlugin::setVolume(qreal volume) | 308 | void MPrisPlugin::setVolume(qreal volume) | ||
301 | { | 309 | { | ||
302 | sendData(QStringLiteral("setVolume"), { | 310 | sendData(QStringLiteral("setVolume"), { | ||
303 | {QStringLiteral("volume"), volume} | 311 | {QStringLiteral("volume"), volume} | ||
304 | }); | 312 | }); | ||
▲ Show 20 Lines • Show All 284 Lines • Show Last 20 Lines |