Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit 2fba419

Browse files
ykztsGargron
authored andcommitted
Add boop sounds in Vorbis format (mastodon#2963)
Vorbis is audio format of Open Source. Can play audio in a free environment where you can not play mp3.
1 parent fd66f7c commit 2fba419

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

app/javascript/mastodon/middleware/sounds.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
const createAudio = sources => {
2+
const audio = new Audio();
3+
sources.forEach(({ type, src }) => {
4+
const source = document.createElement('source');
5+
source.type = type;
6+
source.src = src;
7+
audio.appendChild(source);
8+
});
9+
return audio;
10+
}
11+
112
const play = audio => {
213
if (!audio.paused) {
314
audio.pause();
@@ -9,7 +20,16 @@ const play = audio => {
920

1021
export default function soundsMiddleware() {
1122
const soundCache = {
12-
boop: new Audio(['/sounds/boop.mp3'])
23+
boop: createAudio([
24+
{
25+
src: '/sounds/boop.ogg',
26+
type: 'audio/ogg',
27+
},
28+
{
29+
src: '/sounds/boop.mp3',
30+
type: 'audio/mpeg'
31+
},
32+
]),
1333
};
1434

1535
return ({ dispatch }) => next => (action) => {

public/sounds/boop.ogg

5.04 KB
Binary file not shown.

0 commit comments

Comments
 (0)