move
This commit is contained in:
59
src/store/modules/videos/actions.js
Normal file
59
src/store/modules/videos/actions.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import axios from 'axios'
|
||||
import router from '../../../router'
|
||||
|
||||
export default {
|
||||
play(context, video) {
|
||||
context.commit("selectVideo", video);
|
||||
if (context.rootGetters.routerQuery.play != video._id) {
|
||||
router.push("/boxes?id=" + video.parent._id + "&play=" + video._id);
|
||||
}
|
||||
},
|
||||
playContainer(context, container) {
|
||||
context.dispatch("play", container.videos[0]);
|
||||
},
|
||||
playNextTo(context, video) {
|
||||
context.commit("resetSelectedVideo");
|
||||
let currentIndex = video.parent.videos.indexOf(video);
|
||||
if (currentIndex < video.parent.videos.length - 1) {
|
||||
context.dispatch("play", video.parent.videos[currentIndex + 1]);
|
||||
}
|
||||
},
|
||||
convertNextTo(context, payload) {
|
||||
let currentIndex = payload.video.parent.videos.indexOf(payload.video);
|
||||
if (currentIndex < payload.video.parent.videos.length - 1) {
|
||||
let nextVideo = payload.video.parent.videos[currentIndex + 1]
|
||||
axios.get(context.rootGetters.server + "/api/videos/" + nextVideo._id + "/convert/" + (context.rootGetters["user/settings"].video_quality || "realtime") + "/" + payload.langIndex).then(() => {
|
||||
console.log("Pre Convert started for: " + nextVideo.title);
|
||||
});
|
||||
}
|
||||
},
|
||||
resetSelectedVideo(context) {
|
||||
if (!context.getters.selectedVideo._id) {
|
||||
return;
|
||||
}
|
||||
let box_id = context.getters.selectedVideo.parent._id;
|
||||
context.commit("resetSelectedVideo");
|
||||
if (context.rootGetters.routerQuery.play)
|
||||
router.push("/boxes?id=" + box_id);
|
||||
},
|
||||
upload(context, form) {
|
||||
let h = context.rootGetters.headers;
|
||||
h.headers["content-type"] = "multipart/form-data";
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.post(context.rootGetters.server + "/api/videos", form, h)
|
||||
.then(() => {
|
||||
resolve();
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
},
|
||||
loadMostViewed(context) {
|
||||
axios.get(context.rootGetters.server + "/api/videos/most_viewed", context.rootGetters.headers)
|
||||
.then((res) => {
|
||||
context.commit("setMostViewed", res.data);
|
||||
});
|
||||
},
|
||||
}
|
||||
11
src/store/modules/videos/getters.js
Normal file
11
src/store/modules/videos/getters.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export default {
|
||||
selectedVideo(state) {
|
||||
return state.selectedVideo;
|
||||
},
|
||||
getStreamUrl(state, getters, rootState, rootGetters) {
|
||||
return rootGetters.server + "/api/videos/" + state.selectedVideo._id + "/stream/" + (rootGetters["user/settings"].video_quality || "realtime") + "/"
|
||||
},
|
||||
mostViewed(state) {
|
||||
return state.mostViewed;
|
||||
}
|
||||
}
|
||||
12
src/store/modules/videos/index.js
Normal file
12
src/store/modules/videos/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import state from './state.js';
|
||||
import getters from './getters.js';
|
||||
import mutations from './mutations.js';
|
||||
import actions from './actions.js';
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
14
src/store/modules/videos/mutations.js
Normal file
14
src/store/modules/videos/mutations.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export default {
|
||||
selectVideo(state, video) {
|
||||
state.selectedVideo = video;
|
||||
},
|
||||
resetSelectedVideo(state) {
|
||||
if (!state.selectedVideo._id) {
|
||||
return;
|
||||
}
|
||||
state.selectedVideo = { tracks: [] };
|
||||
},
|
||||
setMostViewed(state, tracks) {
|
||||
state.mostViewed = tracks;
|
||||
}
|
||||
}
|
||||
4
src/store/modules/videos/state.js
Normal file
4
src/store/modules/videos/state.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
selectedVideo: { tracks: [] },
|
||||
mostViewed: []
|
||||
}
|
||||
Reference in New Issue
Block a user