1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-21 05:52:49 +00:00

feat: add favorites - update dependencies

This commit is contained in:
2020-06-11 22:41:02 -05:00
parent b7d13ee5fd
commit 58170df201
18 changed files with 3040 additions and 2307 deletions

View File

@@ -1,5 +1,4 @@
import { SoundType } from '../components/sound-list/sound-list';
import { ISound } from '../model';
import { ISound, SoundListType, SoundType } from '../model';
import { axios } from './axios.service';
const playSound = (sound: SoundType): Promise<any> => {
@@ -11,7 +10,15 @@ const getSounds = async (): Promise<ISound[]> => {
return res.data.data;
};
export const playAudioInBrowser = (sound: SoundType, type: SoundListType) => {
const t = type === 'favorites' ? 'sounds' : type;
const url = `/public/${t.toLowerCase()}/` + sound.name + '.' + sound.extension;
const audio = new Audio(url);
audio.play();
};
export const SoundService = {
getSounds,
playSound,
playAudioInBrowser,
};