5180 fichiers 38.5 Mo 0 téléchargements 185 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / api / utils / PlaySound.ts
PlaySound.ts 681 o Télécharger le fichier
import { MouseEventType, OctaneSoundEvent } from '@octane/renderer';
import { DispatchMainEvent } from '../events';

let canPlaySound = false;

export const PlaySound = (sampleCode: string) => {
    if (!canPlaySound) return;

    DispatchMainEvent(new OctaneSoundEvent(OctaneSoundEvent.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();
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser