Skip to content

A self-hosted media server and file management system

feat: video auto play option

aminnausin79dc70894110
diff --git a/package-lock.json b/package-lock.json
index ea73abb3..db6589a9 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -29,6 +29,7 @@
"@iconify-json/circum": "^1.1.11",
"@iconify-json/formkit": "^1.2.2",
"@iconify-json/lucide": "^1.1.202",
+ "@iconify-json/mage": "^1.2.2",
"@iconify-json/majesticons": "^1.2.1",
"@iconify-json/material-symbols-light": "^1.1.25",
"@iconify-json/mdi-light": "^1.2.1",
@@ -992,6 +993,16 @@
"@iconify/types": "*"
}
},
+ "node_modules/@iconify-json/mage": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@iconify-json/mage/-/mage-1.2.2.tgz",
+ "integrity": "sha512-sCn5NRf4MrKjGzElJ7LtZHCNcyTEc/+szCAgpuOujaL7Qhht+cMNwmKXJmlcCcezxiOmL0TDjwdzQZ5xkSkJhw==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@iconify/types": "*"
+ }
+ },
"node_modules/@iconify-json/majesticons": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@iconify-json/majesticons/-/majesticons-1.2.2.tgz",
diff --git a/package.json b/package.json
index 6cf67985..7b1b7802 100755
--- a/package.json
+++ b/package.json
@@ -37,6 +37,7 @@
"@iconify-json/circum": "^1.1.11",
"@iconify-json/formkit": "^1.2.2",
"@iconify-json/lucide": "^1.1.202",
+ "@iconify-json/mage": "^1.2.2",
"@iconify-json/majesticons": "^1.2.1",
"@iconify-json/material-symbols-light": "^1.1.25",
"@iconify-json/mdi-light": "^1.2.1",
diff --git a/resources/js/App.vue b/resources/js/App.vue
index 1fb6176d..1e5525d1 100755
--- a/resources/js/App.vue
+++ b/resources/js/App.vue
@@ -10,15 +10,16 @@ import { RouterView } from 'vue-router';
import ToastController from '@/components/pinesUI/ToastController.vue';
import ContextMenu from '@/components/pinesUI/ContextMenu.vue';
-const appStore = useAppStore();
const toastPosition = ref<ToastPostion>();
-const { lightMode, ambientMode, playbackHeatmap, contextMenuItems, contextMenuStyle, contextMenuItemStyle } = storeToRefs(appStore);
-const { toggleDarkMode, initDarkMode, initAmbientMode, setAmbientMode, initPlaybackHeatmap, setPlaybackHeatmap } = appStore;
+
+const { lightMode, ambientMode, playbackHeatmap, contextMenuItems, contextMenuStyle, contextMenuItemStyle, isPlaylist } = storeToRefs(useAppStore());
+const { toggleDarkMode, initDarkMode, initAmbientMode, initPlaybackHeatmap, initIsPlaylist, setAmbientMode, setPlaybackHeatmap, setIsPlaylist } = useAppStore();
onMounted(async () => {
initDarkMode();
initAmbientMode();
initPlaybackHeatmap();
+ initIsPlaylist();
const screenSize = getScreenSize();
if (screenSize === 'default') {
@@ -31,6 +32,7 @@ onMounted(async () => {
watch(ambientMode, setAmbientMode, { immediate: false });
watch(lightMode, toggleDarkMode, { immediate: false });
watch(playbackHeatmap, setPlaybackHeatmap, { immediate: false });
+watch(isPlaylist, setIsPlaylist, { immediate: false });
</script>
<template>
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index 7cff0f81..2e9bf37f 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -41,6 +41,7 @@ import ProiconsReverse from '~icons/proicons/reverse';
import ProiconsVolume from '~icons/proicons/volume';
import ProiconsCancel from '~icons/proicons/cancel';
import ProiconsPlay from '~icons/proicons/play';
+import MagePlaylist from '~icons/mage/playlist';
import CircumTimer from '~icons/circum/timer';
/**
@@ -60,12 +61,10 @@ const router = useRouter();
const emit = defineEmits(['loadedData', 'seeked', 'play', 'pause', 'ended', 'loadedMetadata']);
// Global State
-const { playbackHeatmap, ambientMode, lightMode, isAutoPlay } = storeToRefs(useAppStore());
+const { playbackHeatmap, ambientMode, lightMode, isAutoPlay, isPlaylist } = storeToRefs(useAppStore());
const { createRecord, updateViewCount } = useContentStore();
const { setContextMenu } = useAppStore();
-const { userData } = storeToRefs(useAuthStore()) as unknown as {
- userData: Ref<UserResource>;
-};
+const { userData } = storeToRefs(useAuthStore()) as unknown as { userData: Ref<UserResource> };
const { stateVideo, stateFolder, nextVideoURL, previousVideoURL } = storeToRefs(useContentStore()) as unknown as {
stateVideo: Ref<VideoResource>;
stateFolder: Ref<FolderResource | { id?: number; name?: string; series?: Series; path?: string }>;
@@ -103,15 +102,15 @@ const isPictureInPicture = ref(false);
const isChangingVolume = ref(false);
const isShowingParty = ref(false);
const isShowingStats = ref(false);
+const isMediaSession = ref(false);
+const isFastForward = ref(false);
const isFullScreen = ref(false);
const isLoading = ref(true);
const isSeeking = ref(false);
const isLooping = ref(false);
+const isRewind = ref(false);
const isPaused = ref(true);
const isMuted = ref(false);
-const isFastForward = ref(false);
-const isRewind = ref(false);
-const isMediaSession = ref(false);
// Player Info
const endsAtTime = ref('00:00');
@@ -220,6 +219,19 @@ const videoPopoverItems = computed(() => {
playbackHeatmap.value = !playbackHeatmap.value;
},
},
+ {
+ text: 'Playlist',
+ title: 'Toggle Autoplay',
+ icon: MagePlaylist,
+ selectedIcon: ProiconsCheckmark,
+ selected: isPlaylist.value ?? false,
+ selectedIconStyle: 'text-purple-600',
+ action: () => {
+ if (isLoading.value) return;
+ isPlaylist.value = !isPlaylist.value;
+ isAutoPlay.value = isPlaylist.value;
+ },
+ },
{
text: 'Miniplayer',
title: 'Toggle Picture-in-picture',
@@ -421,6 +433,12 @@ const onPlayerEnded = () => {
}
emit('ended');
+
+ if (isPlaylist.value) {
+ handleNext(true);
+ return;
+ }
+
onPlayerPause();
};
@@ -714,7 +732,10 @@ const handleLoadSavedVolume = () => {
};
const handleNext = (useAutoPlay = isAudio.value) => {
- if (!nextVideoURL.value) return;
+ if (!nextVideoURL.value) {
+ toast.info('Reached end of playlist');
+ return;
+ }
isAutoPlay.value = useAutoPlay;
router.push(nextVideoURL.value);
};
diff --git a/resources/js/stores/AppStore.ts b/resources/js/stores/AppStore.ts
index e65763ae..c3809c7d 100644
--- a/resources/js/stores/AppStore.ts
+++ b/resources/js/stores/AppStore.ts
@@ -8,25 +8,26 @@ import ContextMenu from '@/components/pinesUI/ContextMenu.vue';
import Echo from 'laravel-echo';
export const useAppStore = defineStore('App', () => {
+ const { data: rawAppManifest } = useGetManifest();
+
const ws = ref<Echo<keyof Broadcaster> | null>(null);
const pageTitle = ref('');
const lightMode = ref<null | boolean>(null);
const ambientMode = ref<null | boolean>(null);
const playbackHeatmap = ref<null | boolean>(null);
+ const isPlaylist = ref<null | boolean>(null);
const isAutoPlay = ref<boolean>(false);
const selectedSideBar = ref('');
const sideBarTarget = ref('');
const scrollLock = ref(false);
+ const contextMenu = useTemplateRef<InstanceType<typeof ContextMenu> | null>('contextMenu');
const contextMenuItems = ref<ContextMenuItem[]>([]);
- const contextMenuStyle = ref('');
- const contextMenuItemStyle = ref('');
const contextMenuEvent = ref<MouseEvent>();
+ const contextMenuItemStyle = ref('');
+ const contextMenuStyle = ref('');
- const contextMenu = useTemplateRef<InstanceType<typeof ContextMenu> | null>('contextMenu');
-
- const { data: rawAppManifest } = useGetManifest();
const appManifest = ref<AppManifest>({ version: 'Unversioned', commit: null });
function toggleDarkMode() {
@@ -71,6 +72,19 @@ export const useAppStore = defineStore('App', () => {
localStorage.setItem('playbackHeatmap', booleanToString(playbackHeatmap.value));
}
+ function setIsPlaylist() {
+ localStorage.setItem('isPlaylist', booleanToString(isPlaylist.value));
+ }
+
+ function initIsPlaylist() {
+ let init = isPlaylist.value === null;
+ let cachedState = localStorage.getItem('isPlaylist');
+ if (!init) return;
+
+ isPlaylist.value = cachedState === 'true';
+ localStorage.setItem('isPlaylist', booleanToString(isPlaylist.value));
+ }
+
async function cycleSideBar(target = '', scrollTarget: '' | 'left-card' | 'list-card' | 'root' = '', scrollToTarget = true) {
sideBarTarget.value = scrollTarget;
@@ -132,6 +146,9 @@ export const useAppStore = defineStore('App', () => {
initPlaybackHeatmap,
setPlaybackHeatmap,
playbackHeatmap,
+ initIsPlaylist,
+ setIsPlaylist,
+ isPlaylist,
cycleSideBar,
selectedSideBar,
sideBarTarget,
@@ -146,7 +163,7 @@ export const useAppStore = defineStore('App', () => {
createEcho,
disconnectEcho,
isAutoPlay,
- ws,
appManifest,
+ ws,
};
});