mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-03-05 10:01:12 +08:00
Merge branch 'dev'
This commit is contained in:
commit
c74c47564e
@ -118,7 +118,7 @@ export default {
|
|||||||
high: "High",
|
high: "High",
|
||||||
lossless: "Lossless",
|
lossless: "Lossless",
|
||||||
},
|
},
|
||||||
deviceSelector: "Output Device",
|
deviceSelector: "Audio Output Device",
|
||||||
appearance: {
|
appearance: {
|
||||||
text: "Appearance",
|
text: "Appearance",
|
||||||
auto: "Auto",
|
auto: "Auto",
|
||||||
|
@ -152,33 +152,19 @@ 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: false,
|
html5: true,
|
||||||
format: ["mp3", "flac"],
|
format: ["mp3", "flac"],
|
||||||
});
|
});
|
||||||
if (autoplay) {
|
if (autoplay) {
|
||||||
this.play();
|
this.play();
|
||||||
document.title = `${this._currentTrack.name} · ${this._currentTrack.ar[0].name} - YesPlayMusic`;
|
document.title = `${this._currentTrack.name} · ${this._currentTrack.ar[0].name} - YesPlayMusic`;
|
||||||
}
|
}
|
||||||
|
this.setOutputDevice();
|
||||||
|
// this._updatePositionState();
|
||||||
this._howler.once("end", () => {
|
this._howler.once("end", () => {
|
||||||
this._nextTrackCallback();
|
this._nextTrackCallback();
|
||||||
});
|
});
|
||||||
@ -272,6 +258,9 @@ export default class {
|
|||||||
navigator.mediaSession.setActionHandler("stop", () => {
|
navigator.mediaSession.setActionHandler("stop", () => {
|
||||||
this.pause();
|
this.pause();
|
||||||
});
|
});
|
||||||
|
navigator.mediaSession.setActionHandler("seekto", (event) => {
|
||||||
|
this.seek(event.seekTime);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_updateMediaSessionMetaData(track) {
|
_updateMediaSessionMetaData(track) {
|
||||||
@ -292,6 +281,15 @@ export default class {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// _updatePositionState() {
|
||||||
|
// if ('setPositionState' in navigator.mediaSession) {
|
||||||
|
// navigator.mediaSession.setPositionState({
|
||||||
|
// duration: this._currentTrack.dt / 1000,
|
||||||
|
// playbackRate: 1,
|
||||||
|
// position: this.seek(),
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }
|
||||||
_nextTrackCallback() {
|
_nextTrackCallback() {
|
||||||
this._scrobble(true);
|
this._scrobble(true);
|
||||||
if (this.repeatMode === "one") {
|
if (this.repeatMode === "one") {
|
||||||
@ -358,6 +356,10 @@ export default class {
|
|||||||
this.volume = 0;
|
this.volume = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setOutputDevice() {
|
||||||
|
if (this._howler._sounds.length <= 0) return;
|
||||||
|
this._howler._sounds[0]._node.setSinkId(store.state.settings.outputDevice);
|
||||||
|
}
|
||||||
|
|
||||||
replacePlaylist(
|
replacePlaylist(
|
||||||
trackIDs,
|
trackIDs,
|
||||||
|
@ -248,7 +248,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["settings", "data"]),
|
...mapState(["player", "settings", "data"]),
|
||||||
isElectron() {
|
isElectron() {
|
||||||
return process.env.IS_ELECTRON;
|
return process.env.IS_ELECTRON;
|
||||||
},
|
},
|
||||||
@ -305,7 +305,7 @@ export default {
|
|||||||
if (deviceId === this.settings.outputDevice || deviceId === undefined)
|
if (deviceId === this.settings.outputDevice || deviceId === undefined)
|
||||||
return;
|
return;
|
||||||
this.$store.commit("changeOutputDevice", deviceId);
|
this.$store.commit("changeOutputDevice", deviceId);
|
||||||
document.querySelector("audio").setSinkId(deviceId); // Change output device
|
this.player.setOutputDevice();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
showGithubIcon: {
|
showGithubIcon: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user