Skip to content

Commit

Permalink
#1678: Enable react-player for audio file resources
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 committed Feb 26, 2024
1 parent 16559ab commit e67c8ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const mediaMap = {
gltf: Scene3DViewer,
pcd: Scene3DViewer,
ifc: Scene3DViewer,
audio: MediaComponent,
unsupported: UnsupportedViewer
};

Expand Down
3 changes: 3 additions & 0 deletions geonode_mapstore_client/client/js/utils/FileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const getFileFromDownload = (downloadURL, type = 'application/pdf') => {
// Default Supported resources for MediaViewer
export const imageExtensions = ['jpg', 'jpeg', 'png'];
export const videoExtensions = ['mp4', 'mpg', 'avi', 'm4v', 'mp2', '3gp', 'flv', 'vdo', 'afl', 'mpga', 'webm'];
export const audioExtensions = ['mp3', 'wav', 'ogg'];
export const gltfExtensions = ['glb', 'gltf'];
export const pcdExtensions = ['pcd'];
export const ifcExtensions = ['ifc'];
Expand All @@ -52,6 +53,8 @@ export const determineResourceType = extension => {
if (gltfExtensions.includes(extension)) return 'gltf';
if (pcdExtensions.includes(extension)) return 'pcd';
if (ifcExtensions.includes(extension)) return 'ifc';
if (ifcExtensions.includes(extension)) return 'ifc';
if (audioExtensions.includes(extension)) return 'video';
return 'unsupported';
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ describe('FileUtils', () => {
expect(mediaType).toEqual('unsupported');
});

it('should return video if extension is a supported audio format', () => {
const mediaType = determineResourceType('mp3');
expect(mediaType).toEqual('video');
});

it('should always return file extension in lowercase', () => {
const file = {
name: 'test file.ZIP'
Expand Down

0 comments on commit e67c8ae

Please # to comment.