add warning

This commit is contained in:
JerryXiao 2022-01-13 13:27:15 +08:00
parent c51ccda65b
commit 838f11aa77
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
2 changed files with 117 additions and 3 deletions

View file

@ -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) {

View file

@ -5,10 +5,100 @@
<meta name="viewport" content="width=device-width" />
<title>Control Your Player</title>
<link rel="stylesheet" href="cyp.css" />
<style>
/* Float cancel and delete buttons and add an equal width */
.popupbtn {
background-color: rgb(141, 0, 0);
color: rgb(255, 255, 255);
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
display: block !important;
box-sizing: border-box;
}
.popupbtn:hover {
opacity:1;
}
/* Add padding and center-align text to the container */
.popupcontainer {
padding: 16px;
text-align: center;
}
/* The Modal (background) */
.popupmodal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 2; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: #474e5d;
padding-top: 50px;
}
/* Modal Content/Box */
.popupmodal-content {
background-color: #fefefe;
margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size */
}
/* Style the horizontal ruler */
.popup-hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}
/* The Modal Close Button (x) */
.popup-close {
position: absolute;
right: 35px;
top: 15px;
font-size: 40px;
font-weight: bold;
color: #f1f1f1;
}
.popup-close:hover,
.popup-close:focus {
color: #f44336;
cursor: pointer;
}
/* Clear floats */
.popup-clearfix::after {
content: "";
clear: both;
display: table;
}
</style>
<link rel="icon" href="https://emojimage.toad.cz/🎵" />
<meta name="mobile-web-app-capable" content="yes" />
</head>
<body>
<div id="warningpopup" class="popupmodal">
<span onclick="document.getElementById('warningpopup').style.display='none'" class="popup-close" title="x">×</span>
<div class="popupmodal-content">
<div class="popupcontainer">
<h2>Warning</h2>
<p>Be aware there may be other users listening to the same stream.</p>
<p>Pausing or changing volume on the server will affect them as well.</p>
<p>Please avoid server-side pausing or volume change if possible.</p>
<p>You can find client-side volume and pause control in the Settings Panel.</p>
<div class="popup-clearfix">
<button type="button" onclick="document.getElementById('warningpopup').style.display='none'" class="popupbtn">OK</button>
</div>
</div>
</div>
</div>
<cyp-app theme="dark" color="dodgerblue">
<header>
<cyp-player>