0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-12-01 15:37:29 +00:00
VueTube/NUXT/store/player/index.js

52 lines
1.5 KiB
JavaScript
Raw Normal View History

export const state = () => ({
loop: null,
speed: 1,
speedAutosave: null,
preload: null,
2022-07-29 04:44:26 +00:00
preloadUpTo: 100,
2022-07-28 20:20:18 +00:00
// quality: null,
// qualityAutoSwitch: null,
// shortFullscreen: null,
// autoplay: null,
// shorts: null,
// music: null,
});
export const mutations = {
2022-07-28 20:20:18 +00:00
initPlayer(state) {
if (process.client) {
state.loop =
localStorage.getItem("loop") !== "undefined"
? JSON.parse(localStorage.getItem("loop"))
: true; // defaults to false
2022-07-28 20:20:18 +00:00
state.speed = JSON.parse(localStorage.getItem("speed")) || 1; // defaults to 1
state.speedAutosave = !(
// false if false, defaults to true
(JSON.parse(localStorage.getItem("speedAutosave")) === false)
);
state.preload = JSON.parse(localStorage.getItem("preload")) === true; // defaults to false
2022-07-29 04:44:26 +00:00
state.preloadUpTo =
JSON.parse(localStorage.getItem("preloadUpTo")) || 100; // defaults to 100(percent)
2022-07-28 20:20:18 +00:00
}
},
setLoop(state, payload) {
state.loop = payload;
2022-07-28 20:20:18 +00:00
localStorage.setItem("loop", payload);
},
setSpeed(state, payload) {
state.speed = payload;
2022-07-28 20:20:18 +00:00
localStorage.setItem("speed", payload);
},
setSpeedAutosave(state, payload) {
state.speedAutosave = payload;
2022-07-28 20:20:18 +00:00
localStorage.setItem("speedAutosave", payload);
},
setPreload(state, payload) {
state.preload = payload;
2022-07-28 20:20:18 +00:00
localStorage.setItem("preload", payload);
},
2022-07-29 04:44:26 +00:00
setPreloadUpTo(state, payload) {
state.preloadUpTo = payload;
localStorage.setItem("preloadUpTo", payload);
},
};