mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-05 21:18:30 -04:00
osd/media playback: delay showing until album art is ready and avoid
re-showing when duplicate metadata comes from mpris related #2787 port 1.5
This commit is contained in:
@@ -23,7 +23,7 @@ DankOSD {
|
|||||||
if (!player) {
|
if (!player) {
|
||||||
_displayIcon = "music_note";
|
_displayIcon = "music_note";
|
||||||
iconDebounce.stop();
|
iconDebounce.stop();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
let icon = "music_note";
|
let icon = "music_note";
|
||||||
switch (player.playbackState) {
|
switch (player.playbackState) {
|
||||||
@@ -35,10 +35,13 @@ DankOSD {
|
|||||||
icon = "play_arrow";
|
icon = "play_arrow";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (icon === _displayIcon)
|
if (icon === _displayIcon) {
|
||||||
return;
|
iconDebounce.stop();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
iconDebounce.pendingIcon = icon;
|
iconDebounce.pendingIcon = icon;
|
||||||
iconDebounce.restart();
|
iconDebounce.restart();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePlaying() {
|
function togglePlaying() {
|
||||||
@@ -52,6 +55,29 @@ DankOSD {
|
|||||||
property string _displayArtist: ""
|
property string _displayArtist: ""
|
||||||
property string _displayAlbum: ""
|
property string _displayAlbum: ""
|
||||||
|
|
||||||
|
function _showPending() {
|
||||||
|
_pendingShow = false;
|
||||||
|
pendingShowFallback.stop();
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function _evaluateShow() {
|
||||||
|
// art url can land in a later metadata update than the title
|
||||||
|
if (TrackArtService.getArtworkUrl(player) === "") {
|
||||||
|
_pendingShow = true;
|
||||||
|
pendingShowFallback.interval = 600;
|
||||||
|
pendingShowFallback.restart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (TrackArtService.artReadyFor(player) && artPreloader.status === Image.Ready) {
|
||||||
|
_showPending();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_pendingShow = true;
|
||||||
|
pendingShowFallback.interval = 1500;
|
||||||
|
pendingShowFallback.restart();
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: iconDebounce
|
id: iconDebounce
|
||||||
interval: 150
|
interval: 150
|
||||||
@@ -59,6 +85,17 @@ DankOSD {
|
|||||||
onTriggered: root._displayIcon = pendingIcon
|
onTriggered: root._displayIcon = pendingIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: pendingShowFallback
|
||||||
|
interval: 1500
|
||||||
|
onTriggered: {
|
||||||
|
if (!root._pendingShow)
|
||||||
|
return;
|
||||||
|
root._pendingShow = false;
|
||||||
|
root.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: artPreloader
|
id: artPreloader
|
||||||
source: TrackArtService.resolvedArtUrl
|
source: TrackArtService.resolvedArtUrl
|
||||||
@@ -70,6 +107,7 @@ DankOSD {
|
|||||||
onPlayerChanged: {
|
onPlayerChanged: {
|
||||||
if (!player) {
|
if (!player) {
|
||||||
_pendingShow = false;
|
_pendingShow = false;
|
||||||
|
pendingShowFallback.stop();
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,12 +115,19 @@ DankOSD {
|
|||||||
Connections {
|
Connections {
|
||||||
target: TrackArtService
|
target: TrackArtService
|
||||||
function onLoadingChanged() {
|
function onLoadingChanged() {
|
||||||
if (TrackArtService.loading || !root._pendingShow)
|
if (!root._pendingShow)
|
||||||
|
return;
|
||||||
|
if (TrackArtService.loading) {
|
||||||
|
pendingShowFallback.interval = 1500;
|
||||||
|
pendingShowFallback.restart();
|
||||||
return;
|
return;
|
||||||
if (!TrackArtService.resolvedArtUrl || artPreloader.status === Image.Ready) {
|
|
||||||
root._pendingShow = false;
|
|
||||||
root.show();
|
|
||||||
}
|
}
|
||||||
|
if (!TrackArtService.resolvedArtUrl) {
|
||||||
|
root._showPending();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (TrackArtService.artReadyFor(root.player) && artPreloader.status === Image.Ready)
|
||||||
|
root._showPending();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +139,7 @@ DankOSD {
|
|||||||
switch (artPreloader.status) {
|
switch (artPreloader.status) {
|
||||||
case Image.Ready:
|
case Image.Ready:
|
||||||
case Image.Error:
|
case Image.Error:
|
||||||
root._pendingShow = false;
|
root._showPending();
|
||||||
root.show();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,26 +156,32 @@ DankOSD {
|
|||||||
if (MprisController.isFirefoxYoutubeHoverPreview(player))
|
if (MprisController.isFirefoxYoutubeHoverPreview(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
root._displayTitle = player.trackTitle || "";
|
const newTitle = player.trackTitle || "";
|
||||||
root._displayArtist = player.trackArtist || "";
|
const newArtist = player.trackArtist || "";
|
||||||
root._displayAlbum = player.trackAlbum || "";
|
const newAlbum = player.trackAlbum || "";
|
||||||
|
const trackChanged = newTitle !== root._displayTitle || newArtist !== root._displayArtist || newAlbum !== root._displayAlbum;
|
||||||
|
|
||||||
root.updatePlaybackIcon();
|
root._displayTitle = newTitle;
|
||||||
const resolvedArtUrl = TrackArtService.resolvedArtUrl;
|
root._displayArtist = newArtist;
|
||||||
|
root._displayAlbum = newAlbum;
|
||||||
|
|
||||||
if (!resolvedArtUrl || resolvedArtUrl === "") {
|
const iconChanged = root.updatePlaybackIcon();
|
||||||
|
|
||||||
|
// live streams re-emit metadata as mpris:length grows - ignore churn
|
||||||
|
if (!trackChanged && !iconChanged)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// vertical layout has no art background
|
||||||
|
if (root.useVertical) {
|
||||||
root.show();
|
root.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (TrackArtService.loading) {
|
if (trackChanged) {
|
||||||
root._pendingShow = true;
|
root._evaluateShow();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!TrackArtService.resolvedArtUrl || artPreloader.status === Image.Ready) {
|
if (!root._pendingShow)
|
||||||
root.show();
|
root.show();
|
||||||
return;
|
|
||||||
}
|
|
||||||
root._pendingShow = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTrackArtUrlChanged() {
|
function onTrackArtUrlChanged() {
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ DankOSD {
|
|||||||
Connections {
|
Connections {
|
||||||
target: AudioService.source?.audio ?? null
|
target: AudioService.source?.audio ?? null
|
||||||
|
|
||||||
// Sync only - apps adjusting mic gain (WebRTC AGC etc.) fire this
|
// sync only - app AGC rewrites mic gain constantly, must not surface the OSD
|
||||||
// constantly, so external volume changes must not surface the OSD
|
|
||||||
function onVolumeChanged() {
|
function onVolumeChanged() {
|
||||||
root._syncVolume();
|
root._syncVolume();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,11 @@ Singleton {
|
|||||||
return (p.trackTitle || "") + "" + (p.trackArtist || "") + "" + (p.trackAlbum || "");
|
return (p.trackTitle || "") + "" + (p.trackArtist || "") + "" + (p.trackAlbum || "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function artReadyFor(player) {
|
||||||
|
const url = getArtworkUrl(player);
|
||||||
|
return url !== "" && url === _lastArtUrl && !loading && resolvedArtUrl !== "";
|
||||||
|
}
|
||||||
|
|
||||||
function _updateArtUrl() {
|
function _updateArtUrl() {
|
||||||
const key = _trackKey();
|
const key = _trackKey();
|
||||||
// Skip once real art is committed for this track (dedup Chrome's multi-size
|
// Skip once real art is committed for this track (dedup Chrome's multi-size
|
||||||
|
|||||||
Reference in New Issue
Block a user