nanka iroiro (#6853)
* wip * Update maps.ts * wip * wip * wip * wip * Update base.vue * wip * wip * wip * wip * Update link.vue * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update privacy.vue * wip * wip * wip * wip * Update range.vue * wip * wip * wip * wip * Update profile.vue * wip * Update a.vue * Update index.vue * wip * Update sidebar.vue * wip * wip * Update account-info.vue * Update a.vue * wip * wip * Update sounds.vue * wip * wip * wip * wip * wip * wip * wip * wip * Update account-info.vue * Update account-info.vue * wip * wip * wip * Update d-persimmon.json5 * wip
This commit is contained in:
24
src/client/scripts/sound.ts
Normal file
24
src/client/scripts/sound.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { device } from '@/cold-storage';
|
||||
|
||||
const cache = new Map<string, HTMLAudioElement>();
|
||||
|
||||
export function play(type: string) {
|
||||
const sound = device.get('sound_' + type as any);
|
||||
if (sound.type == null) return;
|
||||
playFile(sound.type, sound.volume);
|
||||
}
|
||||
|
||||
export function playFile(file: string, volume: number) {
|
||||
const masterVolume = device.get('sound_masterVolume');
|
||||
if (masterVolume === 0) return;
|
||||
|
||||
let audio: HTMLAudioElement;
|
||||
if (cache.has(file)) {
|
||||
audio = cache.get(file);
|
||||
} else {
|
||||
audio = new Audio(`/assets/sounds/${file}.mp3`);
|
||||
cache.set(file, audio);
|
||||
}
|
||||
audio.volume = masterVolume - ((1 - volume) * masterVolume);
|
||||
audio.play();
|
||||
}
|
@ -15,19 +15,12 @@ export const darkTheme: Theme = require('../themes/_dark.json5');
|
||||
export const themeProps = Object.keys(lightTheme.props).filter(key => !key.startsWith('X'));
|
||||
|
||||
export const builtinThemes = [
|
||||
require('../themes/l-white.json5'),
|
||||
require('../themes/l-red.json5'),
|
||||
require('../themes/l-green.json5'),
|
||||
require('../themes/l-blue.json5'),
|
||||
require('../themes/l-light.json5'),
|
||||
require('../themes/l-apricot.json5'),
|
||||
|
||||
require('../themes/d-black.json5'),
|
||||
require('../themes/d-red.json5'),
|
||||
require('../themes/d-green.json5'),
|
||||
require('../themes/d-blue.json5'),
|
||||
require('../themes/d-dark.json5'),
|
||||
require('../themes/d-persimmon.json5'),
|
||||
|
||||
require('../themes/d-battery-saver.json5'),
|
||||
require('../themes/d-black.json5'),
|
||||
] as Theme[];
|
||||
|
||||
let timeout = null;
|
||||
|
Reference in New Issue
Block a user