From 838f11aa77495ffc38018910c39e99bdd020cab5 Mon Sep 17 00:00:00 2001 From: Jerry Date: Thu, 13 Jan 2022 13:27:15 +0800 Subject: [PATCH] add warning --- app/cyp.js | 30 +++++++++++++++-- app/index.html | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 3 deletions(-) diff --git a/app/cyp.js b/app/cyp.js index 8f93972..821f9e4 100644 --- a/app/cyp.js +++ b/app/cyp.js @@ -1110,7 +1110,15 @@ class Player extends Component { const DOM = this._dom; DOM.play.addEventListener("click", _ => this._app.mpd.command("play")); - DOM.pause.addEventListener("click", _ => this._app.mpd.command("pause 1")); + DOM.pause.addEventListener("click", _ => { + if (!this.multiuser_warned) { + this.multiuser_warned = true; + document.getElementById("warningpopup").style.display="block"; + } + else { + this._app.mpd.command("pause 1"); + } + }); DOM.prev.addEventListener("click", _ => this._app.mpd.command("previous")); DOM.next.addEventListener("click", _ => this._app.mpd.command("next")); @@ -1130,8 +1138,24 @@ class Player extends Component { this._app.mpd.command(`seekcur ${elapsed}`); }); - DOM.volume.addEventListener("input", e => this._app.mpd.command(`setvol ${e.target.valueAsNumber}`)); - DOM.mute.addEventListener("click", _ => this._app.mpd.command(`setvol ${this._toggleVolume}`)); + DOM.volume.addEventListener("input", e => { + if (!this.multiuser_warned) { + this.multiuser_warned = true; + document.getElementById("warningpopup").style.display="block"; + } + else { + this._app.mpd.command(`setvol ${e.target.valueAsNumber}`); + } + }); + DOM.mute.addEventListener("click", _ => { + if (!this.multiuser_warned) { + this.multiuser_warned = true; + document.getElementById("warningpopup").style.display="block"; + } + else { + this._app.mpd.command(`setvol ${this._toggleVolume}`) + } + }); } _dispatchSongChange(detail) { diff --git a/app/index.html b/app/index.html index ec16b4d..0d09bef 100644 --- a/app/index.html +++ b/app/index.html @@ -5,10 +5,100 @@ Control Your Player + +
+ × +
+
+

Warning

+

Be aware there may be other users listening to the same stream.

+

Pausing or changing volume on the server will affect them as well.

+

Please avoid server-side pausing or volume change if possible.

+

You can find client-side volume and pause control in the Settings Panel.

+ +
+
+