mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2024-11-26 10:13:47 +08:00
Merge branch 'dev'
This commit is contained in:
commit
970124f70d
|
@ -118,6 +118,7 @@ export default {
|
||||||
high: "High",
|
high: "High",
|
||||||
lossless: "Lossless",
|
lossless: "Lossless",
|
||||||
},
|
},
|
||||||
|
deviceSelector: "Output Device",
|
||||||
appearance: {
|
appearance: {
|
||||||
text: "Appearance",
|
text: "Appearance",
|
||||||
auto: "Auto",
|
auto: "Auto",
|
||||||
|
|
|
@ -119,6 +119,7 @@ export default {
|
||||||
high: "极高",
|
high: "极高",
|
||||||
lossless: "无损",
|
lossless: "无损",
|
||||||
},
|
},
|
||||||
|
deviceSelector: "音频输出设备",
|
||||||
appearance: {
|
appearance: {
|
||||||
text: "外观",
|
text: "外观",
|
||||||
auto: "自动",
|
auto: "自动",
|
||||||
|
|
|
@ -7,6 +7,7 @@ let localStorage = {
|
||||||
lang: null,
|
lang: null,
|
||||||
appearance: "auto",
|
appearance: "auto",
|
||||||
musicQuality: 320000,
|
musicQuality: 320000,
|
||||||
|
outputDevice: "default",
|
||||||
showGithubIcon: true,
|
showGithubIcon: true,
|
||||||
showPlaylistsByAppleMusic: true,
|
showPlaylistsByAppleMusic: true,
|
||||||
showUnavailableSongInGreyStyle: true,
|
showUnavailableSongInGreyStyle: true,
|
||||||
|
|
|
@ -9,6 +9,9 @@ export default {
|
||||||
changeMusicQuality(state, value) {
|
changeMusicQuality(state, value) {
|
||||||
state.settings.musicQuality = value;
|
state.settings.musicQuality = value;
|
||||||
},
|
},
|
||||||
|
changeOutputDevice(state, deviceId) {
|
||||||
|
state.settings.outputDevice = deviceId;
|
||||||
|
},
|
||||||
updateSettings(state, { key, value }) {
|
updateSettings(state, { key, value }) {
|
||||||
state.settings[key] = value;
|
state.settings[key] = value;
|
||||||
},
|
},
|
||||||
|
|
|
@ -102,6 +102,8 @@ export default class {
|
||||||
|
|
||||||
_init() {
|
_init() {
|
||||||
Howler.autoUnlock = false;
|
Howler.autoUnlock = false;
|
||||||
|
Howler.usingWebAudio = true;
|
||||||
|
Howler.masterGain = true;
|
||||||
this._loadSelfFromLocalStorage();
|
this._loadSelfFromLocalStorage();
|
||||||
this._replaceCurrentTrack(this._currentTrack.id, false).then(() => {
|
this._replaceCurrentTrack(this._currentTrack.id, false).then(() => {
|
||||||
this._howler.seek(localStorage.getItem("playerCurrentTrackTime") ?? 0);
|
this._howler.seek(localStorage.getItem("playerCurrentTrackTime") ?? 0);
|
||||||
|
@ -150,11 +152,27 @@ export default class {
|
||||||
time,
|
time,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
_setupAudioNode() {
|
||||||
|
Howler.masterGain.disconnect();
|
||||||
|
const mediaStreamNode = Howler.ctx.createMediaStreamDestination();
|
||||||
|
Howler.masterGain.connect(mediaStreamNode);
|
||||||
|
let audio = '';
|
||||||
|
if (document.querySelector('audio') !== null) {
|
||||||
|
audio = document.querySelector('audio');
|
||||||
|
} else {
|
||||||
|
audio = document.createElement('audio');
|
||||||
|
document.body.append(audio);
|
||||||
|
}
|
||||||
|
audio.autoplay = true;
|
||||||
|
audio.srcObject = mediaStreamNode.stream;
|
||||||
|
audio.setSinkId(store.state.settings.outputDevice);
|
||||||
|
}
|
||||||
_playAudioSource(source, autoplay = true) {
|
_playAudioSource(source, autoplay = true) {
|
||||||
Howler.unload();
|
Howler.unload();
|
||||||
|
this._setupAudioNode();
|
||||||
this._howler = new Howl({
|
this._howler = new Howl({
|
||||||
src: [source],
|
src: [source],
|
||||||
html5: true,
|
html5: false,
|
||||||
format: ["mp3", "flac"],
|
format: ["mp3", "flac"],
|
||||||
});
|
});
|
||||||
if (autoplay) {
|
if (autoplay) {
|
||||||
|
|
|
@ -545,28 +545,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.playlist-info {
|
|
||||||
width: calc(100vw - 2 * var(--main-content-padding-x));
|
|
||||||
display: block;
|
|
||||||
|
|
||||||
.cover {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info {
|
|
||||||
margin-top: 24px;
|
|
||||||
margin-left: 0;
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: 48px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.special-playlist {
|
.special-playlist {
|
||||||
margin-top: 192px;
|
margin-top: 192px;
|
||||||
margin-bottom: 128px;
|
margin-bottom: 128px;
|
||||||
|
|
|
@ -74,6 +74,18 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="item">
|
||||||
|
<div class="left">
|
||||||
|
<div class="title"> {{ $t("settings.deviceSelector") }} </div>
|
||||||
|
</div>
|
||||||
|
<div class="right">
|
||||||
|
<select v-model="outputDevice">
|
||||||
|
<option v-for="device in allOutputDevices" :key="device.deviceId" :value="device.deviceId" :selected="device.deviceId == outputDevice">
|
||||||
|
{{ device.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
|
@ -227,6 +239,7 @@ export default {
|
||||||
size: "0KB",
|
size: "0KB",
|
||||||
length: 0,
|
length: 0,
|
||||||
},
|
},
|
||||||
|
allOutputDevices: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -270,6 +283,19 @@ export default {
|
||||||
this.clearCache("tracks");
|
this.clearCache("tracks");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
outputDevice: {
|
||||||
|
get() {
|
||||||
|
if (this.allOutputDevices.length == 0) this.getAllOutputDevices(); // Ensure devices loaded before get
|
||||||
|
const isValidDevice = this.allOutputDevices.find(device => device.deviceId === this.settings.outputDevice);
|
||||||
|
if (this.settings.outputDevice === undefined || isValidDevice === undefined) return "default"; // Default deviceId
|
||||||
|
return this.settings.outputDevice;
|
||||||
|
},
|
||||||
|
set(deviceId) {
|
||||||
|
if (deviceId === this.settings.outputDevice || deviceId === undefined) return;
|
||||||
|
this.$store.commit("changeOutputDevice", deviceId);
|
||||||
|
document.querySelector("audio").setSinkId(deviceId); // Change output device
|
||||||
|
},
|
||||||
|
},
|
||||||
showGithubIcon: {
|
showGithubIcon: {
|
||||||
get() {
|
get() {
|
||||||
if (this.settings.showGithubIcon === undefined) return true;
|
if (this.settings.showGithubIcon === undefined) return true;
|
||||||
|
@ -356,6 +382,11 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getAllOutputDevices() {
|
||||||
|
return navigator.mediaDevices.enumerateDevices().then(
|
||||||
|
devices => this.allOutputDevices = devices.filter(device => device.kind == "audiooutput")
|
||||||
|
);
|
||||||
|
},
|
||||||
logout() {
|
logout() {
|
||||||
doLogout();
|
doLogout();
|
||||||
this.$router.push({ name: "home" });
|
this.$router.push({ name: "home" });
|
||||||
|
|
Loading…
Reference in New Issue
Block a user