We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 12e65b5 + ea96e1b commit 1532601Copy full SHA for 1532601
1 file changed
src/core/player/MediaSessionManager.ts
@@ -16,6 +16,7 @@ import {
16
enableDiscordRpc,
17
updateDiscordConfig,
18
} from "./PlayerIpc";
19
+import { throttle } from "lodash-es";
20
21
/**
22
* 媒体会话管理器,负责控制媒体控件相关功能
@@ -236,14 +237,21 @@ class MediaSessionManager {
236
237
return;
238
}
239
240
+ this.throttledUpdatePositionState(duration, position);
241
+ }
242
243
+ /**
244
+ * 媒体会话进度更新限流
245
+ * 频繁的更新会导致 Linux 下的 MPRIS 进度条抽搐,因此限制更新频率
246
+ */
247
+ private throttledUpdatePositionState = throttle((duration: number, position: number) => {
248
if ("mediaSession" in navigator) {
249
navigator.mediaSession.setPositionState({
250
duration: msToS(duration),
251
position: msToS(position),
252
});
253
- }
254
+ }, 1000);
255
256
257
0 commit comments