Skip to content

Commit

Permalink
feat(media): add more supported file extensions
Browse files Browse the repository at this point in the history
closes #45
  • Loading branch information
BenShelton committed Jun 8, 2021
1 parent 19086dc commit b1862c0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
9 changes: 8 additions & 1 deletion packages/media/app/main/src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@library-api/core'
import { MediaDetailsDTO } from '@library-api/core/types/dto'

import { imageExtensions, videoExtensions } from 'shared/extensions'
import { initDirectories } from './directories'
import { getControlWindow, getDisplayWindow } from './window'
import { CATALOG_PATH, DOWNLOAD_DIR, VIDEO_DIR } from './constants'
Expand Down Expand Up @@ -151,7 +152,13 @@ export function initIPC (): void {
title: 'Choose the media you want to display',
defaultPath: app.getPath('downloads'),
filters: [
{ name: 'Media', extensions: ['jpg', 'png', 'gif', 'mp4', 'avi'] }
{
name: 'Media',
extensions: [
...imageExtensions,
...videoExtensions
]
}
]
})
if (canceled || !filePaths.length) return false
Expand Down
13 changes: 6 additions & 7 deletions packages/media/app/renderer/src/pages/Display.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<script lang="ts">
import { defineComponent, ref } from 'vue'
import { imageExtensions, videoExtensions } from 'shared/extensions'
import { DisplayMedia, DisplayClear } from 'shared/types/ipc'
export default defineComponent({
Expand All @@ -43,15 +45,12 @@ export default defineComponent({
mediaType.value = 'image'
} else {
const ext = args.src.split('.').pop()
switch (ext) {
case 'jpg':
case 'png':
case 'gif':
if (ext) {
if (imageExtensions.includes(ext)) {
mediaType.value = 'image'
break
case 'mp4':
case 'avi':
} else if (videoExtensions.includes(ext)) {
mediaType.value = 'video'
}
}
}
src.value = args.src
Expand Down
16 changes: 16 additions & 0 deletions packages/media/app/shared/extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const imageExtensions = [
'jpg', 'jpeg',
'gif',
'png',
'bmp',
'svg',
'webp',
'ico'
]

export const videoExtensions = [
'mp4', 'm4p', 'm4v',
'ogg',
'mov',
'webm'
]

0 comments on commit b1862c0

Please sign in to comment.