click volume button to mute and unclick to go back to lastVolume

This commit is contained in:
Jason Chen 2022-01-19 19:19:47 -08:00
parent 7bc77b2b1d
commit c36b47bd93
5 changed files with 50 additions and 5 deletions

View file

@ -24,6 +24,8 @@ export class ConfigStore {
}, },
"audio": { "audio": {
"volume": 1, "volume": 1,
"lastVolume": 1,
"muted": false,
"quality": "990", "quality": "990",
"seamless_audio": true, "seamless_audio": true,
"normalization": false, "normalization": false,

View file

@ -518,7 +518,16 @@ const app = new Vue({
} }
MusicKitInterop.init() MusicKitInterop.init()
// Set the volume // Set the volume
// Check the value of this.cfg.audio.muted
if( !this.cfg.audio.muted )
{
// Set the mk.volume to the last stored volume data
this.mk.volume = this.cfg.audio.volume this.mk.volume = this.cfg.audio.volume
} else if( this.cfg.audio.muted ) {
// Set mk.volume to -1 (setting to 0 wont work, so temp solution setting to -1)
this.mk.volume = -1;
}
// ipcRenderer.invoke('getStoreValue', 'audio.volume').then((value) => { // ipcRenderer.invoke('getStoreValue', 'audio.volume').then((value) => {
// self.mk.volume = value // self.mk.volume = value
// }) // })
@ -2984,6 +2993,17 @@ const app = new Vue({
} }
} }
}, },
muteButtonPressed() {
if( this.cfg.audio.muted ) {
this.mk.volume = this.cfg.audio.lastVolume;
this.cfg.audio.muted = false;
} else {
this.cfg.audio.lastVolume = this.cfg.audio.volume;
this.mk.volume = 0;
this.cfg.audio.muted = true;
}
},
async apiCall(url, callback) { async apiCall(url, callback) {
const xmlHttp = new XMLHttpRequest(); const xmlHttp = new XMLHttpRequest();

View file

@ -4103,6 +4103,29 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb {
width: 100% width: 100%
} }
.volume-button--small {
border-radius: 6px;
color: inherit;
background-size: 16px;
background-repeat: no-repeat;
background-position: center;
background-color: transparent;
height: 15px;
width: 30px;
border: 0px;
box-shadow: unset;
opacity: 0.70;
background-image: url("./assets/feather/volume-2.svg");
}
.volume-button--small:active {
transform: scale(0.9);
}
.volume-button--small.active {
background-image: url("./assets/feather/volume.svg");
}
input[type=range] { input[type=range] {
-webkit-appearance: none; -webkit-appearance: none;
height: 4px; height: 4px;

View file

@ -78,8 +78,8 @@
</div> </div>
</div> </div>
<div class="app-chrome-item volume display--large"> <div class="app-chrome-item volume display--large">
<div class="app-chrome-item volume-icon"></div>
<div class="input-container"> <div class="input-container">
<button class="volume-button--small volume" @click="app.muteButtonPressed()" :class="{'active': app.cfg.audio.volume == 0}"></button>
<input type="range" class="slider" @wheel="app.volumeWheel" step="0.01" min="0" max="1" v-model="app.mk.volume" <input type="range" class="slider" @wheel="app.volumeWheel" step="0.01" min="0" max="1" v-model="app.mk.volume"
v-if="typeof app.mk.volume != 'undefined'"> v-if="typeof app.mk.volume != 'undefined'">
</div> </div>

View file

@ -131,7 +131,7 @@
</div> </div>
<div class="app-chrome--right"> <div class="app-chrome--right">
<div class="app-chrome-item volume display--large"> <div class="app-chrome-item volume display--large">
<button class="volume-button--small volume"></button> <button class="volume-button--small volume" @click="muteButtonPressed()" :class="{'active': this.cfg.audio.volume == 0}"></button>
<input type="range" class="" @wheel="volumeWheel" step="0.01" min="0" max="1" <input type="range" class="" @wheel="volumeWheel" step="0.01" min="0" max="1"
v-model="mk.volume" v-model="mk.volume"
v-if="typeof mk.volume != 'undefined'"> v-if="typeof mk.volume != 'undefined'">
@ -293,7 +293,7 @@
</div> </div>
<div class="app-chrome-item volume"> <div class="app-chrome-item volume">
<div class="input-container"> <div class="input-container">
<div class="app-chrome-item volume-icon"></div> <button class="volume-button--small volume" @click="muteButtonPressed()" :class="{'active': this.cfg.audio.volume == 0}"></button>
<input type="range" class="" @wheel="volumeWheel" step="0.01" min="0" max="1" <input type="range" class="" @wheel="volumeWheel" step="0.01" min="0" max="1"
v-model="mk.volume" v-model="mk.volume"
v-if="typeof mk.volume != 'undefined'"> v-if="typeof mk.volume != 'undefined'">