mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 23:16:21 +00:00
🆙 Init V3
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { MouseEventType, NitroSoundEvent } from '@nitrots/nitro-renderer';
|
||||
import { DispatchMainEvent } from '../events';
|
||||
|
||||
let canPlaySound = false;
|
||||
|
||||
export const PlaySound = (sampleCode: string) =>
|
||||
{
|
||||
if(!canPlaySound) return;
|
||||
|
||||
DispatchMainEvent(new NitroSoundEvent(NitroSoundEvent.PLAY_SOUND, sampleCode));
|
||||
};
|
||||
|
||||
const eventTypes = [ MouseEventType.MOUSE_CLICK ];
|
||||
|
||||
const startListening = () =>
|
||||
{
|
||||
const stopListening = () => eventTypes.forEach(type => window.removeEventListener(type, onEvent));
|
||||
|
||||
const onEvent = (event: Event) => ((canPlaySound = true) && stopListening());
|
||||
|
||||
eventTypes.forEach(type => window.addEventListener(type, onEvent));
|
||||
};
|
||||
|
||||
startListening();
|
||||
Reference in New Issue
Block a user