2020-04-07 11:56:46 -04:00
|
|
|
<template>
|
2024-04-08 11:07:03 -04:00
|
|
|
<div class="h-full">
|
2024-04-16 12:13:28 -04:00
|
|
|
<PlayerControl />
|
2024-04-08 11:07:03 -04:00
|
|
|
<div class="flex justify-end p-1">
|
|
|
|
<div>
|
2024-04-09 09:45:17 -04:00
|
|
|
<VueDatePicker
|
|
|
|
v-model="listDate"
|
|
|
|
:clearable="false"
|
|
|
|
:hide-navigation="['time']"
|
|
|
|
:action-row="{ showCancel: false, showSelect: false, showPreview: false }"
|
|
|
|
:format="calendarFormat"
|
|
|
|
model-type="yyyy-MM-dd"
|
|
|
|
auto-apply
|
2024-04-13 18:01:45 -04:00
|
|
|
:locale="locale"
|
2024-04-09 11:21:13 -04:00
|
|
|
:dark="colorMode.value === 'dark'"
|
2024-04-17 06:32:07 -04:00
|
|
|
input-class-name="input input-sm !input-bordered !w-[300px] text-right !pe-3"
|
2024-04-09 09:45:17 -04:00
|
|
|
required
|
|
|
|
/>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-09 09:45:17 -04:00
|
|
|
<div class="p-1 min-h-[260px] h-[calc(100vh-800px)] xl:h-[calc(100vh-480px)]">
|
|
|
|
<splitpanes class="border border-my-gray rounded shadow">
|
|
|
|
<pane
|
2024-04-15 11:08:44 -04:00
|
|
|
v-if="width > 768"
|
2024-04-09 09:45:17 -04:00
|
|
|
class="relative h-full !bg-base-300 rounded-s"
|
|
|
|
min-size="0"
|
|
|
|
max-size="80"
|
2024-04-15 11:08:44 -04:00
|
|
|
size="20"
|
2024-04-09 09:45:17 -04:00
|
|
|
>
|
2024-04-16 02:57:45 -04:00
|
|
|
<MediaBrowser :preview="setPreviewData" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</pane>
|
|
|
|
<pane>
|
2024-04-16 02:57:45 -04:00
|
|
|
<PlaylistTable
|
|
|
|
:get-playlist="getPlaylist"
|
|
|
|
:edit-item="editPlaylistItem"
|
|
|
|
:preview="setPreviewData"
|
|
|
|
/>
|
2024-04-08 11:07:03 -04:00
|
|
|
</pane>
|
|
|
|
</splitpanes>
|
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-09 09:45:17 -04:00
|
|
|
<div class="h-16 join flex justify-end p-3">
|
2024-04-13 18:01:45 -04:00
|
|
|
<button class="btn btn-sm btn-primary join-item" :title="$t('player.copy')" @click="showCopyModal = true">
|
2023-01-11 04:54:25 -05:00
|
|
|
<i class="bi-files" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</button>
|
|
|
|
<button
|
2024-04-17 03:55:57 -04:00
|
|
|
v-if="!configStore.playout.playlist.loop"
|
2024-04-08 11:07:03 -04:00
|
|
|
class="btn btn-sm btn-primary join-item"
|
2024-04-13 18:01:45 -04:00
|
|
|
:title="$t('player.loop')"
|
2023-01-11 04:54:25 -05:00
|
|
|
@click="loopClips()"
|
|
|
|
>
|
|
|
|
<i class="bi-view-stacked" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
class="btn btn-sm btn-primary join-item"
|
2024-04-13 18:01:45 -04:00
|
|
|
:title="$t('player.remote')"
|
2024-04-08 11:07:03 -04:00
|
|
|
@click="showSourceModal = true"
|
2023-01-11 04:54:25 -05:00
|
|
|
>
|
|
|
|
<i class="bi-file-earmark-plus" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
class="btn btn-sm btn-primary join-item"
|
2024-04-13 18:01:45 -04:00
|
|
|
:title="$t('player.import')"
|
2024-04-08 15:33:28 -04:00
|
|
|
@click="showImportModal = true"
|
2023-01-11 04:54:25 -05:00
|
|
|
>
|
|
|
|
<i class="bi-file-text" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
class="btn btn-sm btn-primary join-item"
|
2024-04-13 18:01:45 -04:00
|
|
|
:title="$t('player.generate')"
|
2024-04-08 15:33:28 -04:00
|
|
|
@click="mediaStore.getTree('', true), (showPlaylistGenerator = true)"
|
2023-01-22 14:04:57 -05:00
|
|
|
>
|
2023-01-11 04:54:25 -05:00
|
|
|
<i class="bi-sort-down-alt" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</button>
|
2024-04-17 03:55:57 -04:00
|
|
|
<button
|
|
|
|
class="btn btn-sm btn-primary join-item"
|
|
|
|
:title="$t('player.reset')"
|
|
|
|
@click=";(playlistStore.playlist.length = 0), getPlaylist()"
|
|
|
|
>
|
2023-01-11 04:54:25 -05:00
|
|
|
<i class="bi-arrow-counterclockwise" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
class="btn btn-sm btn-primary join-item"
|
2024-04-13 18:01:45 -04:00
|
|
|
:title="$t('player.save')"
|
2024-04-08 15:33:28 -04:00
|
|
|
@click=";(targetDate = listDate), savePlaylist(true)"
|
2024-04-08 11:07:03 -04:00
|
|
|
>
|
2024-04-08 15:33:28 -04:00
|
|
|
<i class="bi-download" />
|
|
|
|
</button>
|
2024-04-14 15:52:31 -04:00
|
|
|
<button
|
|
|
|
class="btn btn-sm btn-primary join-item"
|
|
|
|
:title="$t('player.deletePlaylist')"
|
|
|
|
@click="showDeleteModal = true"
|
|
|
|
>
|
2023-01-11 04:54:25 -05:00
|
|
|
<i class="bi-trash" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2024-04-16 12:13:28 -04:00
|
|
|
<GenericModal
|
2024-04-09 09:45:17 -04:00
|
|
|
:show="showPreviewModal"
|
|
|
|
:title="`Preview: ${previewName}`"
|
|
|
|
:hide-buttons="true"
|
|
|
|
:modal-action="closePlayer"
|
|
|
|
>
|
2024-04-08 11:07:03 -04:00
|
|
|
<div class="w-[1024px] max-w-full aspect-video">
|
|
|
|
<VideoPlayer v-if="isVideo && previewOpt" reference="previewPlayer" :options="previewOpt" />
|
2024-04-17 03:55:57 -04:00
|
|
|
<img v-else :src="previewUrl" class="img-fluid" :alt="previewName" />
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-16 12:13:28 -04:00
|
|
|
</GenericModal>
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-16 12:13:28 -04:00
|
|
|
<GenericModal :show="showSourceModal" title="Add/Edit Source" :modal-action="processSource">
|
2024-04-08 11:07:03 -04:00
|
|
|
<div>
|
|
|
|
<label class="form-control w-full mt-3">
|
|
|
|
<div class="label">
|
|
|
|
<span class="label-text">In</span>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-17 03:55:57 -04:00
|
|
|
<input v-model.number="newSource.in" type="number" class="input input-sm input-bordered w-full" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="form-control w-full mt-3">
|
|
|
|
<div class="label">
|
|
|
|
<span class="label-text">Out</span>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-17 03:55:57 -04:00
|
|
|
<input v-model.number="newSource.out" type="number" class="input input-sm input-bordered w-full" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</label>
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-08 11:07:03 -04:00
|
|
|
<label class="form-control w-full mt-3">
|
|
|
|
<div class="label">
|
|
|
|
<span class="label-text">Duration</span>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-08 11:07:03 -04:00
|
|
|
<input
|
2024-04-16 12:13:28 -04:00
|
|
|
v-model.number="newSource.duration"
|
2024-04-08 11:07:03 -04:00
|
|
|
type="number"
|
|
|
|
class="input input-sm input-bordered w-full"
|
2024-04-17 03:55:57 -04:00
|
|
|
/>
|
2024-04-08 11:07:03 -04:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="form-control w-full mt-3">
|
|
|
|
<div class="label">
|
|
|
|
<span class="label-text">Source</span>
|
|
|
|
</div>
|
2024-04-17 03:55:57 -04:00
|
|
|
<input v-model="newSource.source" type="text" class="input input-sm input-bordered w-full" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="form-control w-full mt-3">
|
|
|
|
<div class="label">
|
|
|
|
<span class="label-text">Audio</span>
|
|
|
|
</div>
|
2024-04-17 03:55:57 -04:00
|
|
|
<input v-model="newSource.audio" type="text" class="input input-sm input-bordered w-full" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="form-control w-full mt-3">
|
|
|
|
<div class="label">
|
|
|
|
<span class="label-text">Custom Filter</span>
|
|
|
|
</div>
|
2024-04-17 03:55:57 -04:00
|
|
|
<input v-model="newSource.custom_filter" type="text" class="input input-sm input-bordered w-full" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<div class="form-control">
|
|
|
|
<label class="cursor-pointer label">
|
|
|
|
<span class="label-text">Advertisement</span>
|
2024-04-17 03:55:57 -04:00
|
|
|
<input type="checkbox" class="checkbox checkbox-sm" @click="isAd" />
|
2024-04-08 11:07:03 -04:00
|
|
|
</label>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-16 12:13:28 -04:00
|
|
|
</GenericModal>
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-16 12:13:28 -04:00
|
|
|
<GenericModal :show="showImportModal" title="Import Playlist" :modal-action="importPlaylist">
|
2024-04-08 15:33:28 -04:00
|
|
|
<input
|
|
|
|
type="file"
|
|
|
|
class="file-input file-input-sm file-input-bordered w-full"
|
|
|
|
multiple
|
2024-04-16 12:13:28 -04:00
|
|
|
@change="onFileChange"
|
2024-04-17 03:55:57 -04:00
|
|
|
/>
|
2024-04-16 12:13:28 -04:00
|
|
|
</GenericModal>
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-16 12:13:28 -04:00
|
|
|
<GenericModal :show="showCopyModal" :title="`Copy Program ${listDate}`" :modal-action="savePlaylist">
|
2024-04-17 03:55:57 -04:00
|
|
|
<input v-model="targetDate" type="date" class="input input-sm input-bordered w-full" />
|
2024-04-16 12:13:28 -04:00
|
|
|
</GenericModal>
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-16 12:13:28 -04:00
|
|
|
<GenericModal :show="showDeleteModal" title="Delete Program" :modal-action="deletePlaylist">
|
2024-04-08 15:33:28 -04:00
|
|
|
<span>
|
|
|
|
Delete program from <strong>{{ listDate }}</strong>
|
|
|
|
</span>
|
2024-04-16 12:13:28 -04:00
|
|
|
</GenericModal>
|
2023-01-22 14:04:57 -05:00
|
|
|
|
2024-04-08 15:42:12 -04:00
|
|
|
<PlaylistGenerator v-if="showPlaylistGenerator" :close="closeGenerator" />
|
2020-04-07 11:56:46 -04:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
<script setup lang="ts">
|
2023-03-22 11:01:58 -04:00
|
|
|
import { storeToRefs } from 'pinia'
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-09 09:45:17 -04:00
|
|
|
const colorMode = useColorMode()
|
2024-04-16 08:07:50 -04:00
|
|
|
const { locale, t } = useI18n()
|
2023-01-11 04:54:25 -05:00
|
|
|
const { $_, $dayjs } = useNuxtApp()
|
2024-04-09 09:45:17 -04:00
|
|
|
const { width } = useWindowSize({ initialWidth: 800 })
|
2024-04-16 02:57:45 -04:00
|
|
|
const { mediaType } = stringFormatter()
|
2023-01-11 04:54:25 -05:00
|
|
|
const { processPlaylist, genUID } = playlistOperations()
|
|
|
|
|
|
|
|
const authStore = useAuth()
|
|
|
|
const configStore = useConfig()
|
|
|
|
const indexStore = useIndex()
|
|
|
|
const mediaStore = useMedia()
|
|
|
|
const playlistStore = usePlaylist()
|
|
|
|
|
|
|
|
useHead({
|
2024-04-16 08:07:50 -04:00
|
|
|
title: `${t('button.player')} | ffplayout`,
|
2023-01-11 04:54:25 -05:00
|
|
|
})
|
|
|
|
|
2024-04-08 15:33:28 -04:00
|
|
|
const { listDate } = storeToRefs(usePlaylist())
|
2023-03-22 11:01:58 -04:00
|
|
|
|
2023-04-09 16:28:57 -04:00
|
|
|
const todayDate = ref($dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD'))
|
2023-01-11 04:54:25 -05:00
|
|
|
const targetDate = ref($dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD'))
|
|
|
|
const editId = ref(-1)
|
|
|
|
const textFile = ref()
|
2024-04-08 11:07:03 -04:00
|
|
|
|
|
|
|
const showPreviewModal = ref(false)
|
|
|
|
const showSourceModal = ref(false)
|
2024-04-08 15:33:28 -04:00
|
|
|
const showImportModal = ref(false)
|
|
|
|
const showCopyModal = ref(false)
|
|
|
|
const showDeleteModal = ref(false)
|
|
|
|
const showPlaylistGenerator = ref(false)
|
2024-04-08 11:07:03 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
const previewName = ref('')
|
|
|
|
const previewUrl = ref('')
|
|
|
|
const previewOpt = ref()
|
|
|
|
const isVideo = ref(false)
|
2024-04-08 15:33:28 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
const newSource = ref({
|
|
|
|
begin: 0,
|
|
|
|
in: 0,
|
|
|
|
out: 0,
|
|
|
|
duration: 0,
|
|
|
|
category: '',
|
|
|
|
custom_filter: '',
|
|
|
|
source: '',
|
2023-02-02 03:53:26 -05:00
|
|
|
audio: '',
|
2023-07-14 07:45:48 -04:00
|
|
|
uid: '',
|
2023-01-11 04:54:25 -05:00
|
|
|
} as PlaylistItem)
|
|
|
|
|
2023-04-09 16:28:57 -04:00
|
|
|
function scrollTo(index: number) {
|
2024-04-15 11:08:44 -04:00
|
|
|
const child = document.getElementById(`clip-${index}`)
|
|
|
|
const parent = document.getElementById('playlist-container')
|
2023-04-09 16:28:57 -04:00
|
|
|
|
2023-06-28 05:01:17 -04:00
|
|
|
if (child && parent) {
|
2023-04-09 16:28:57 -04:00
|
|
|
const topPos = child.offsetTop
|
|
|
|
parent.scrollTop = topPos - 50
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-09 09:45:17 -04:00
|
|
|
const calendarFormat = (date: Date) => {
|
2024-04-15 11:39:41 -04:00
|
|
|
return $dayjs(date).locale(locale.value).format('dddd - LL')
|
2024-04-09 09:45:17 -04:00
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
async function getPlaylist() {
|
2024-04-09 09:45:17 -04:00
|
|
|
playlistStore.isLoading = true
|
2023-01-11 04:54:25 -05:00
|
|
|
await playlistStore.getPlaylist(listDate.value)
|
2024-04-09 09:45:17 -04:00
|
|
|
playlistStore.isLoading = false
|
2023-04-09 16:28:57 -04:00
|
|
|
|
|
|
|
if (listDate.value === todayDate.value) {
|
|
|
|
scrollTo(playlistStore.currentClipIndex)
|
|
|
|
} else {
|
|
|
|
scrollTo(0)
|
|
|
|
}
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
2021-03-23 05:43:41 -04:00
|
|
|
|
2024-04-08 15:42:12 -04:00
|
|
|
function closeGenerator() {
|
|
|
|
showPlaylistGenerator.value = false
|
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
function closePlayer() {
|
2024-04-08 11:07:03 -04:00
|
|
|
showPreviewModal.value = false
|
2023-01-11 04:54:25 -05:00
|
|
|
isVideo.value = false
|
|
|
|
}
|
2022-07-05 12:08:51 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
function setPreviewData(path: string) {
|
|
|
|
let fullPath = path
|
2024-04-17 03:55:57 -04:00
|
|
|
const storagePath = configStore.playout.storage.path
|
2023-08-06 17:27:10 -04:00
|
|
|
const lastIndex = storagePath.lastIndexOf('/')
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
if (!path.includes('/')) {
|
|
|
|
const parent = mediaStore.folderTree.parent ? mediaStore.folderTree.parent : ''
|
|
|
|
fullPath = `/${parent}/${mediaStore.folderTree.source}/${path}`.replace(/\/[/]+/g, '/')
|
2023-08-06 17:27:10 -04:00
|
|
|
} else if (lastIndex !== -1) {
|
2024-04-16 08:07:50 -04:00
|
|
|
fullPath = path.replace(storagePath.substring(0, lastIndex), '')
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
2022-07-06 10:22:27 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
previewName.value = fullPath.split('/').slice(-1)[0]
|
2024-04-16 02:57:45 -04:00
|
|
|
showPreviewModal.value = true
|
2023-12-07 16:00:05 -05:00
|
|
|
|
|
|
|
if (path.match(/^http/)) {
|
|
|
|
previewUrl.value = path
|
|
|
|
} else {
|
2024-02-09 05:21:52 -05:00
|
|
|
previewUrl.value = encodeURIComponent(
|
|
|
|
`/file/${configStore.configGui[configStore.configID].id}${fullPath}`
|
|
|
|
).replace(/%2F/g, '/')
|
2023-12-07 16:00:05 -05:00
|
|
|
}
|
2022-07-06 10:22:27 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
const ext = previewName.value.split('.').slice(-1)[0].toLowerCase()
|
2022-09-04 11:05:40 -04:00
|
|
|
|
2023-12-07 16:00:05 -05:00
|
|
|
const fileType =
|
|
|
|
mediaType(previewName.value) === 'audio'
|
|
|
|
? `audio/${ext}`
|
|
|
|
: mediaType(previewName.value) === 'live'
|
|
|
|
? 'application/x-mpegURL'
|
|
|
|
: `video/${ext}`
|
|
|
|
|
2024-04-17 03:55:57 -04:00
|
|
|
if (configStore.playout.storage.extensions.includes(`${ext}`)) {
|
2023-01-11 04:54:25 -05:00
|
|
|
isVideo.value = true
|
|
|
|
previewOpt.value = {
|
|
|
|
liveui: false,
|
|
|
|
controls: true,
|
|
|
|
suppressNotSupportedError: true,
|
|
|
|
autoplay: false,
|
|
|
|
preload: 'auto',
|
|
|
|
sources: [
|
|
|
|
{
|
2023-12-07 16:00:05 -05:00
|
|
|
type: fileType,
|
2023-07-14 07:45:48 -04:00
|
|
|
src: previewUrl.value,
|
|
|
|
},
|
|
|
|
],
|
2020-04-07 11:56:46 -04:00
|
|
|
}
|
2023-01-11 04:54:25 -05:00
|
|
|
} else {
|
|
|
|
isVideo.value = false
|
2020-04-07 11:56:46 -04:00
|
|
|
}
|
|
|
|
}
|
2020-04-17 09:02:11 -04:00
|
|
|
|
2024-04-08 11:07:03 -04:00
|
|
|
function processSource(process: boolean) {
|
|
|
|
showSourceModal.value = false
|
|
|
|
|
|
|
|
if (process) {
|
|
|
|
if (editId.value === -1) {
|
|
|
|
playlistStore.playlist.push(newSource.value)
|
2024-04-17 03:55:57 -04:00
|
|
|
playlistStore.playlist = processPlaylist(listDate.value, playlistStore.playlist, false)
|
2024-04-08 11:07:03 -04:00
|
|
|
} else {
|
|
|
|
playlistStore.playlist[editId.value] = newSource.value
|
2024-04-17 03:55:57 -04:00
|
|
|
playlistStore.playlist = processPlaylist(listDate.value, playlistStore.playlist, false)
|
2024-04-08 11:07:03 -04:00
|
|
|
}
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
2020-04-22 11:19:41 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
editId.value = -1
|
|
|
|
newSource.value = {
|
|
|
|
begin: 0,
|
|
|
|
in: 0,
|
|
|
|
out: 0,
|
|
|
|
duration: 0,
|
|
|
|
category: '',
|
|
|
|
custom_filter: '',
|
|
|
|
source: '',
|
2023-02-02 03:53:26 -05:00
|
|
|
audio: '',
|
2023-07-14 07:45:48 -04:00
|
|
|
uid: genUID(),
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
2020-04-22 11:19:41 -04:00
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
function editPlaylistItem(i: number) {
|
|
|
|
editId.value = i
|
2024-04-16 02:57:45 -04:00
|
|
|
showSourceModal.value = true
|
2020-04-22 11:19:41 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
newSource.value = {
|
|
|
|
begin: playlistStore.playlist[i].begin,
|
|
|
|
in: playlistStore.playlist[i].in,
|
|
|
|
out: playlistStore.playlist[i].out,
|
|
|
|
duration: playlistStore.playlist[i].duration,
|
|
|
|
category: playlistStore.playlist[i].category,
|
|
|
|
custom_filter: playlistStore.playlist[i].custom_filter,
|
|
|
|
source: playlistStore.playlist[i].source,
|
2023-02-02 03:53:26 -05:00
|
|
|
audio: playlistStore.playlist[i].audio,
|
2023-07-14 07:45:48 -04:00
|
|
|
uid: playlistStore.playlist[i].uid,
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
2020-04-22 11:19:41 -04:00
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
function isAd(evt: any) {
|
|
|
|
if (evt.target.checked) {
|
|
|
|
newSource.value.category = 'advertisement'
|
|
|
|
} else {
|
|
|
|
newSource.value.category = ''
|
|
|
|
}
|
2020-04-22 11:19:41 -04:00
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
function loopClips() {
|
|
|
|
const tempList = []
|
|
|
|
let length = 0
|
2020-04-30 11:14:22 -04:00
|
|
|
|
2023-07-14 07:45:48 -04:00
|
|
|
while (length < configStore.playlistLength && playlistStore.playlist.length > 0) {
|
2023-01-11 04:54:25 -05:00
|
|
|
for (const item of playlistStore.playlist) {
|
|
|
|
if (length < configStore.playlistLength) {
|
2024-04-15 14:18:35 -04:00
|
|
|
item.uid = genUID()
|
2023-01-11 04:54:25 -05:00
|
|
|
tempList.push($_.cloneDeep(item))
|
|
|
|
length += item.out - item.in
|
|
|
|
} else {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-30 11:14:22 -04:00
|
|
|
|
2024-04-17 03:55:57 -04:00
|
|
|
playlistStore.playlist = processPlaylist(listDate.value, tempList, false)
|
2020-04-30 11:14:22 -04:00
|
|
|
}
|
|
|
|
|
2024-04-15 15:19:45 -04:00
|
|
|
function onFileChange(evt: any) {
|
|
|
|
const files = evt.target.files || evt.dataTransfer.files
|
|
|
|
|
|
|
|
if (!files.length) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
textFile.value = files
|
|
|
|
}
|
|
|
|
|
2024-04-08 15:33:28 -04:00
|
|
|
async function importPlaylist(imp: boolean) {
|
|
|
|
showImportModal.value = false
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-08 15:33:28 -04:00
|
|
|
if (imp) {
|
|
|
|
if (!textFile.value || !textFile.value[0]) {
|
|
|
|
return
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
2024-04-08 15:33:28 -04:00
|
|
|
|
|
|
|
const formData = new FormData()
|
|
|
|
formData.append(textFile.value[0].name, textFile.value[0])
|
|
|
|
|
2024-04-09 09:45:17 -04:00
|
|
|
playlistStore.isLoading = true
|
2024-04-08 15:33:28 -04:00
|
|
|
await $fetch(
|
2024-04-13 18:01:45 -04:00
|
|
|
`/api/file/${configStore.configGui[configStore.configID].id}/import/?file=${textFile.value[0].name}&date=${
|
|
|
|
listDate.value
|
|
|
|
}`,
|
2024-04-08 15:33:28 -04:00
|
|
|
{
|
|
|
|
method: 'PUT',
|
|
|
|
headers: authStore.authHeader,
|
|
|
|
body: formData,
|
|
|
|
}
|
|
|
|
)
|
2024-04-15 15:19:45 -04:00
|
|
|
.then((response) => {
|
2024-04-16 02:57:45 -04:00
|
|
|
indexStore.msgAlert('success', String(response), 2)
|
2024-04-08 15:33:28 -04:00
|
|
|
playlistStore.getPlaylist(listDate.value)
|
|
|
|
})
|
|
|
|
.catch((e: string) => {
|
2024-04-09 09:45:17 -04:00
|
|
|
indexStore.msgAlert('error', e, 4)
|
2024-04-08 15:33:28 -04:00
|
|
|
})
|
|
|
|
}
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-09 09:45:17 -04:00
|
|
|
playlistStore.isLoading = false
|
2023-01-11 04:54:25 -05:00
|
|
|
textFile.value = null
|
|
|
|
}
|
|
|
|
|
2024-04-08 15:33:28 -04:00
|
|
|
async function savePlaylist(save: boolean) {
|
|
|
|
showCopyModal.value = false
|
2023-09-08 04:16:34 -04:00
|
|
|
|
2024-04-08 15:33:28 -04:00
|
|
|
if (save) {
|
|
|
|
if (playlistStore.playlist.length === 0) {
|
|
|
|
return
|
2023-09-08 04:16:34 -04:00
|
|
|
}
|
2023-01-11 04:54:25 -05:00
|
|
|
|
2024-04-18 10:30:08 -04:00
|
|
|
playlistStore.playlist = processPlaylist(listDate.value, $_.cloneDeep(playlistStore.playlist), true)
|
2024-04-08 15:33:28 -04:00
|
|
|
const saveList = playlistStore.playlist.map(({ begin, ...item }) => item)
|
|
|
|
|
|
|
|
await $fetch(`/api/playlist/${configStore.configGui[configStore.configID].id}/`, {
|
|
|
|
method: 'POST',
|
2024-04-16 08:07:50 -04:00
|
|
|
headers: { ...configStore.contentType, ...authStore.authHeader },
|
2024-04-08 15:33:28 -04:00
|
|
|
body: JSON.stringify({
|
|
|
|
channel: configStore.configGui[configStore.configID].name,
|
|
|
|
date: targetDate.value,
|
|
|
|
program: saveList,
|
|
|
|
}),
|
2023-01-11 04:54:25 -05:00
|
|
|
})
|
2024-04-08 15:33:28 -04:00
|
|
|
.then((response: any) => {
|
2024-04-09 09:45:17 -04:00
|
|
|
indexStore.msgAlert('success', response, 2)
|
2024-04-08 15:33:28 -04:00
|
|
|
})
|
|
|
|
.catch((e: any) => {
|
|
|
|
if (e.status === 409) {
|
2024-04-09 09:45:17 -04:00
|
|
|
indexStore.msgAlert('warning', e.data, 2)
|
2024-04-08 15:33:28 -04:00
|
|
|
} else {
|
2024-04-09 09:45:17 -04:00
|
|
|
indexStore.msgAlert('error', e, 4)
|
2024-04-08 15:33:28 -04:00
|
|
|
}
|
|
|
|
})
|
2023-07-14 07:45:48 -04:00
|
|
|
}
|
2020-05-12 06:12:18 -04:00
|
|
|
}
|
|
|
|
|
2024-04-08 15:33:28 -04:00
|
|
|
async function deletePlaylist(del: boolean) {
|
|
|
|
showDeleteModal.value = false
|
2020-04-30 11:14:22 -04:00
|
|
|
|
2024-04-08 15:33:28 -04:00
|
|
|
if (del) {
|
2024-04-09 09:45:17 -04:00
|
|
|
await $fetch(`/api/playlist/${configStore.configGui[configStore.configID].id}/${listDate.value}`, {
|
2024-04-08 15:33:28 -04:00
|
|
|
method: 'DELETE',
|
2024-04-16 08:07:50 -04:00
|
|
|
headers: { ...configStore.contentType, ...authStore.authHeader },
|
2024-04-08 15:33:28 -04:00
|
|
|
}).then(() => {
|
|
|
|
playlistStore.playlist = []
|
2023-01-22 14:04:57 -05:00
|
|
|
|
2024-04-09 09:45:17 -04:00
|
|
|
indexStore.msgAlert('warning', 'Playlist deleted...', 2)
|
2024-04-08 15:33:28 -04:00
|
|
|
})
|
2023-09-08 04:16:34 -04:00
|
|
|
}
|
|
|
|
}
|
2023-01-11 04:54:25 -05:00
|
|
|
</script>
|
2024-04-15 11:08:44 -04:00
|
|
|
|