summaryrefslogtreecommitdiff
path: root/ext/bg/js/media-utility.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-02-10 19:18:28 -0500
committerGitHub <noreply@github.com>2021-02-10 19:18:28 -0500
commit07cd006127c23c17e5c750122a4ac6916994bc76 (patch)
treede4ab1f7005181790f598d9e12d7ffffc1e09a38 /ext/bg/js/media-utility.js
parent673952e82576b0bc4b6b02c2105fbb1850e55950 (diff)
Add support for multiple types of audio (#1366)
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;
+ }
+ }
}