Refactor sounds, oga -> ogg, remove proprietary avatar from boop.mp3

This commit is contained in:
Alex Gleason 2023-10-15 17:43:53 -05:00
parent 1bfe5908a9
commit 1f7effc97d
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
5 changed files with 13 additions and 20 deletions

View file

@ -1,6 +1,6 @@
# Sound licenses # Sound licenses
- `chat.mp3` - `chat.mp3`
- `chat.oga` - `chat.ogg`
© [notificationsounds.com](https://notificationsounds.com/notification-sounds/intuition-561), licensed under [CC BY 4.0](https://creativecommons.org/licenses/by-sa/4.0/). © [notificationsounds.com](https://notificationsounds.com/notification-sounds/intuition-561), licensed under [CC BY 4.0](https://creativecommons.org/licenses/by-sa/4.0/).

Binary file not shown.

Binary file not shown.

View file

@ -1,10 +1,15 @@
import boopMp3 from 'soapbox/assets/sounds/boop.mp3';
import boopOgg from 'soapbox/assets/sounds/boop.ogg';
import chatMp3 from 'soapbox/assets/sounds/chat.mp3';
import chatOgg from 'soapbox/assets/sounds/chat.ogg';
/** Soapbox audio clip. */ /** Soapbox audio clip. */
type Sound = { interface Sound {
src: string; src: string;
type: string; type: string;
} }
export type Sounds = 'boop' | 'chat' type Sounds = 'boop' | 'chat';
/** Produce HTML5 audio from sound data. */ /** Produce HTML5 audio from sound data. */
const createAudio = (sources: Sound[]): HTMLAudioElement => { const createAudio = (sources: Sound[]): HTMLAudioElement => {
@ -42,25 +47,13 @@ const play = (audio: HTMLAudioElement): Promise<void> => {
const soundCache: Record<Sounds, HTMLAudioElement> = { const soundCache: Record<Sounds, HTMLAudioElement> = {
boop: createAudio([ boop: createAudio([
{ { src: boopOgg, type: 'audio/ogg' },
src: require('../assets/sounds/boop.ogg'), { src: boopMp3, type: 'audio/mpeg' },
type: 'audio/ogg',
},
{
src: require('../assets/sounds/boop.mp3'),
type: 'audio/mpeg',
},
]), ]),
chat: createAudio([ chat: createAudio([
{ { src: chatOgg, type: 'audio/ogg' },
src: require('../assets/sounds/chat.oga'), { src: chatMp3, type: 'audio/mpeg' },
type: 'audio/ogg',
},
{
src: require('../assets/sounds/chat.mp3'),
type: 'audio/mpeg',
},
]), ]),
}; };
export { soundCache, play }; export { soundCache, play, type Sounds };