Skip to content

Commit

Permalink
programaticPause
Browse files Browse the repository at this point in the history
  • Loading branch information
wont-stream committed Jul 13, 2024
1 parent 4683861 commit a988c6e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/DiscordRPC/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const unloadables = [];

const formatLongString = (s) => (s.length >= 128 ? s.slice(0, 125) + "..." : s);

let programaticPause = false;

class WebSocketTransport {
constructor() {
this.ws = null;
Expand Down Expand Up @@ -40,6 +42,7 @@ class WebSocketTransport {
onOpen() {
unloadables.push(
neptune.intercept("playbackControls/TIME_UPDATE", ([current]) => {
if (programaticPause) return;
const { item: currentlyPlaying, type: mediaType } =
neptune.currentMediaItem;

Expand Down Expand Up @@ -96,8 +99,10 @@ class WebSocketTransport {
);

// get the RPC working.
programaticPause = true;
neptune.actions.playbackControls.pause();
neptune.actions.playbackControls.play();
programaticPause = false;
}

onClose(event) {
Expand Down

0 comments on commit a988c6e

Please sign in to comment.