summaryrefslogtreecommitdiff
path: root/ext/bg/js/media-utility.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/media-utility.js')
-rw-r--r--ext/bg/js/media-utility.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/ext/bg/js/media-utility.js b/ext/bg/js/media-utility.js
index b50b2481..b4fbe04d 100644
--- a/ext/bg/js/media-utility.js
+++ b/ext/bg/js/media-utility.js
@@ -98,4 +98,35 @@ class MediaUtility {
return null;
}
}
+
+ /**
+ * Gets the file extension for a corresponding media type.
+ * @param mediaType The media type to use.
+ * @returns A file extension including the dot for the media type,
+ * otherwise null.
+ */
+ getFileExtensionFromAudioMediaType(mediaType) {
+ switch (mediaType) {
+ case 'audio/mpeg':
+ case 'audio/mp3':
+ return '.mp3';
+ case 'audio/mp4':
+ return '.mp4';
+ case 'audio/ogg':
+ case 'audio/vorbis':
+ return '.ogg';
+ case 'audio/vnd.wav':
+ case 'audio/wave':
+ case 'audio/wav':
+ case 'audio/x-wav':
+ case 'audio/x-pn-wav':
+ return '.wav';
+ case 'audio/flac':
+ return '.flac';
+ case 'audio/webm':
+ return '.webm';
+ default:
+ return null;
+ }
+ }
}