123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /* eslint no-param-reassign: 0 */
- const state = {};
- const getters = {};
- const actions = {};
- const mutations = {};
- const modules = {
- songs: {
- namespaced: true,
- state: {
- video: {
- player: null,
- paused: true,
- playerReady: false,
- autoPlayed: false,
- currentTime: 0
- },
- editing: {}
- },
- getters: {},
- actions: {
- editSong: ({ commit }, song) => commit("editSong", song),
- stopVideo: ({ commit }) => commit("stopVideo"),
- loadVideoById: ({ commit }, id, skipDuration) =>
- commit("loadVideoById", id, skipDuration),
- pauseVideo: ({ commit }, status) => commit("pauseVideo", status),
- getCurrentTime: ({ commit, state }, fixedVal) => {
- return new Promise(resolve => {
- commit("getCurrentTime", fixedVal);
- resolve(state.video.currentTime);
- });
- }
- },
- mutations: {
- editSong(state, song) {
- state.editing = { ...song };
- },
- stopVideo(state) {
- state.video.player.stopVideo();
- },
- loadVideoById(state, id, skipDuration) {
- state.video.player.loadVideoById(id, skipDuration);
- },
- pauseVideo(state, status) {
- if (status) state.video.player.pauseVideo();
- else state.video.player.playVideo();
- state.video.paused = status;
- },
- getCurrentTime(state, fixedVal) {
- if (!state.playerReady) state.video.currentTime = 0;
- else {
- Promise.resolve(state.video.player.getCurrentTime()).then(
- time => {
- if (fixedVal)
- Promise.resolve(time.toFixed(fixedVal)).then(
- fixedTime => {
- state.video.currentTime = fixedTime;
- }
- );
- else state.video.currentTime = time;
- }
- );
- }
- }
- }
- },
- stations: {
- namespaced: true,
- state: {
- station: {},
- editing: {}
- },
- getters: {},
- actions: {
- editStation: ({ commit }, station) => commit("editStation", station)
- },
- mutations: {
- editStation(state, station) {
- state.station = station;
- state.editing = JSON.parse(JSON.stringify(station));
- }
- }
- },
- reports: {
- namespaced: true,
- state: {
- report: {}
- },
- getters: {},
- actions: {
- viewReport: ({ commit }, report) => commit("viewReport", report)
- },
- mutations: {
- viewReport(state, report) {
- state.report = report;
- }
- }
- },
- punishments: {
- namespaced: true,
- state: {
- punishment: {}
- },
- getters: {},
- actions: {
- viewPunishment: ({ commit }, punishment) =>
- commit("viewPunishment", punishment)
- },
- mutations: {
- viewPunishment(state, punishment) {
- state.punishment = punishment;
- }
- }
- },
- users: {
- namespaced: true,
- state: {
- editing: {}
- },
- getters: {},
- actions: {
- editUser: ({ commit }, user) => commit("editUser", user)
- },
- mutations: {
- editUser(state, user) {
- state.editing = user;
- }
- }
- }
- };
- export default {
- namespaced: true,
- state,
- getters,
- actions,
- mutations,
- modules
- };
|