Skip to content

Commit

Permalink
fix: audio file thumbnails and time slider and custom duration manage…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
sircharlo committed Nov 11, 2024
1 parent deacae1 commit 6cc6668
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
38 changes: 22 additions & 16 deletions src/components/media/MediaItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
>
<div class="q-pr-none rounded-borders">
<div
v-if="media.isAudio"
class="bg-grey-9 rounded-borders text-white flex"
style="width: 150px; height: 84px"
>
<q-icon name="mmm-music-note" size="lg" />
</div>
<div
v-else
class="q-pr-none rounded-borders overflow-hidden relative-position bg-black"
>
<q-img
Expand All @@ -35,7 +27,7 @@
@mouseleave="setHoveredBadge(media.uniqueId, false)"
>
<q-badge
v-if="media.isVideo"
v-if="media.isVideo || media.isAudio"
:class="
'q-mt-sm q-ml-sm cursor-pointer rounded-borders-sm ' +
(customDurations[currentCongregation]?.[selectedDate]?.[
Expand All @@ -60,7 +52,9 @@
media.uniqueId
]
? 'mmm-edit'
: 'mmm-play'
: props.media.isAudio
? 'mmm-music-note'
: 'mmm-play'
"
class="q-mr-xs"
color="white"
Expand Down Expand Up @@ -293,7 +287,7 @@
<div
v-if="
[media.fileUrl, media.streamUrl].includes(mediaPlayingUrl) &&
media.isVideo
(media.isVideo || media.isAudio)
"
class="absolute duration-slider"
>
Expand Down Expand Up @@ -346,7 +340,10 @@
<template v-if="!media.markers || media.markers.length === 0">
<q-btn
ref="playButton"
:disable="mediaPlayingUrl !== '' && isVideo(mediaPlayingUrl)"
:disable="
mediaPlayingUrl !== '' &&
(isVideo(mediaPlayingUrl) || isAudio(mediaPlayingUrl))
"
color="primary"
icon="mmm-play"
rounded
Expand All @@ -356,7 +353,10 @@
<template v-else>
<q-btn
ref="playButton"
:disable="mediaPlayingUrl !== '' && isVideo(mediaPlayingUrl)"
:disable="
mediaPlayingUrl !== '' &&
(isVideo(mediaPlayingUrl) || isAudio(mediaPlayingUrl))
"
color="primary"
icon="mmm-play-sign-language"
push
Expand Down Expand Up @@ -417,7 +417,7 @@
/>
<q-btn
v-else-if="
media.isVideo &&
(media.isVideo || media.isAudio) &&
(mediaPlayingAction === 'play' || !mediaPlayingAction)
"
ref="pauseResumeButton"
Expand Down Expand Up @@ -550,7 +550,12 @@ import { storeToRefs } from 'pinia';
import { debounce, type QImg } from 'quasar';
import { errorCatcher } from 'src/helpers/error-catcher';
import { getThumbnailUrl } from 'src/helpers/fs';
import { formatTime, isImage, isVideo } from 'src/helpers/mediaPlayback';
import {
formatTime,
isAudio,
isImage,
isVideo,
} from 'src/helpers/mediaPlayback';
import { sendObsSceneEvent } from 'src/helpers/obs';
import { useCurrentStateStore } from 'src/stores/current-state';
import { useJwStore } from 'src/stores/jw';
Expand Down Expand Up @@ -687,7 +692,8 @@ async function findThumbnailUrl() {
}
}
if (props.media.isVideo && !props.media.thumbnailUrl) findThumbnailUrl();
if ((props.media.isVideo || props.media.isAudio) && !props.media.thumbnailUrl)
findThumbnailUrl();
const showMediaDurationPopup = (media: DynamicMediaObject) => {
try {
Expand Down
9 changes: 7 additions & 2 deletions src/helpers/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import type { MultimediaItem, PublicationFetcher } from 'src/types';
import { Buffer } from 'buffer';
import { FULL_HD } from 'src/constants/media';
import { downloadFileIfNeeded, getJwMediaInfo } from 'src/helpers/jw-media';
import { isFileOfType, isImage, isVideo } from 'src/helpers/mediaPlayback';
import {
isAudio,
isFileOfType,
isImage,
isVideo,
} from 'src/helpers/mediaPlayback';
import { useCurrentStateStore } from 'src/stores/current-state';

import { errorCatcher } from './error-catcher';
Expand Down Expand Up @@ -238,7 +243,7 @@ const getThumbnailUrl = async (filepath: string, forceRefresh?: boolean) => {
let thumbnailUrl = '';
if (isImage(filepath)) {
thumbnailUrl = getFileUrl(filepath);
} else if (isVideo(filepath)) {
} else if (isVideo(filepath) || isAudio(filepath)) {
const thumbnailPath = filepath.split('.')[0] + '.jpg';
if (await fs.exists(thumbnailPath)) {
thumbnailUrl = getFileUrl(thumbnailPath);
Expand Down

0 comments on commit 6cc6668

Please sign in to comment.