diff --git a/extension/content-script.js b/extension/content-script.js --- a/extension/content-script.js +++ b/extension/content-script.js @@ -258,6 +258,11 @@ sendPlayerInfo(player, "waiting"); }); + // playlist is now empty or being reloaded, stop player + player.addEventListener("emptied", function () { + sendPlayerInfo(player, "emptied"); + }); + // opposite of "waiting", we finished buffering enough // only if we are playing, though, should we set playback state back to playing player.addEventListener("canplay", function () { diff --git a/extension/extension.js b/extension/extension.js --- a/extension/extension.js +++ b/extension/extension.js @@ -282,7 +282,7 @@ } }); -addRuntimeCallback("mpris", ["paused", "stopped", "waiting", "canplay"], function (message, sender, action) { +addRuntimeCallback("mpris", ["paused", "stopped", "waiting", "canplay", "emptied"], function (message, sender, action) { if (currentPlayerTabId == sender.tab.id) { sendPortMessage("mpris", action); } diff --git a/host/mprisplugin.cpp b/host/mprisplugin.cpp --- a/host/mprisplugin.cpp +++ b/host/mprisplugin.cpp @@ -187,6 +187,11 @@ // opposite of "waiting", only forwarded by our extension when // canplay is emitted with the player *not* paused setPlaybackStatus(QStringLiteral("Playing")); + } else if (event == QLatin1String("emptied")) { + // the media has become empty; for example, this event is sent if the media + // has already been loaded (or partially loaded), and the load() method is called to reload it. + // e.g. when using Ajax page navigation and the user nagivated away + setPlaybackStatus(QStringLiteral("Stopped")); } else if (event == QLatin1String("duration")) { const qreal length = data.value(QStringLiteral("duration")).toDouble();