113 lines
3.6 KiB
TypeScript
113 lines
3.6 KiB
TypeScript
// Metro module 13592 (f13593).
|
|
import MediaEngineStore from "../../../stores/MediaEngineStore";
|
|
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
|
|
import SoundboardStore from "../SoundboardStore";
|
|
import Logger from "../../debug/Logger";
|
|
import BaseSoundboardManager from "../BaseSoundboardManager";
|
|
import getVolumeForSound from "../getVolumeForSound";
|
|
import getSoundboardSoundURL from "../getSoundboardSoundURL";
|
|
import { createSound } from "../../sound_playback/SoundUtils";
|
|
import { reportSoundStartedPlaying, reportSoundFinishedPlaying } from "../SoundboardActionCreators";
|
|
let c9438_7 = new Map();
|
|
let c9438_8 = new Logger("SoundboardManagerNative");
|
|
class SoundboardManager extends BaseSoundboardManager {
|
|
constructor() {
|
|
let c20568_0;
|
|
super(...arguments);
|
|
const _this = this;
|
|
this._stopAndClearSounds = () => {
|
|
c9438_7.forEach((item) => {
|
|
item.stop();
|
|
});
|
|
c9438_7 = new Map();
|
|
};
|
|
this._playSound = function _playSound(a0, r5 = 1) {
|
|
const r3 = arguments[3];
|
|
if (!(SelectedChannelStore.getVoiceChannelId() !== r3 && r3 != null) && !MediaEngineStore.isDeaf()) {
|
|
const userId = arguments[2];
|
|
if (!SoundboardStore.isLocalSoundboardMuted(userId)) {
|
|
const volumeForSound = getVolumeForSound(r5);
|
|
const soundKey = `${userId}-${a0}`;
|
|
const r33 = c9438_7.get(soundKey);
|
|
if (r33 != null) {
|
|
r33.stop();
|
|
}
|
|
const sound = createSound(getSoundboardSoundURL(a0), "soundboard_sound", volumeForSound);
|
|
sound.volume = volumeForSound;
|
|
c9438_7.set(soundKey, sound);
|
|
reportSoundStartedPlaying(a0, userId);
|
|
_this._playSoundWithListener({
|
|
sound,
|
|
soundKey,
|
|
soundId: a0,
|
|
userId
|
|
});
|
|
}
|
|
}
|
|
};
|
|
c20568_0 = void 0;
|
|
c20568_0 = async (c30650_0) => {
|
|
let c30650_3;
|
|
let c30650_4 = 0;
|
|
let c31694_0, c31694_1, c31694_2, c31694_3, c31694_4, c31694_5;
|
|
L14: {
|
|
try {
|
|
c31694_0 = void 0;
|
|
c31694_1 = void 0;
|
|
c31694_2 = void 0;
|
|
c31694_3 = void 0;
|
|
c31694_0 = c30650_0.sound;
|
|
c31694_1 = c30650_0.soundKey;
|
|
c31694_2 = c30650_0.soundId;
|
|
c31694_3 = c30650_0.userId;
|
|
c31694_4 = void 0;
|
|
await void 0;
|
|
c31694_4 = false;
|
|
c30650_4 = 1;
|
|
c31694_4 = await c31694_0.playWithListener();
|
|
c30650_4 = 0;
|
|
if (c31694_4) {
|
|
c9438_7.delete(c31694_1);
|
|
reportSoundFinishedPlaying(c31694_2, c31694_3);
|
|
}
|
|
} catch ($e) {
|
|
const r29 = $e;
|
|
let r7 = r29;
|
|
c30650_3 = r29;
|
|
if (c30650_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r98 = c30650_3;
|
|
c30650_4 = 0;
|
|
c31694_5 = r98;
|
|
c9438_8.error("Failed to play sound", {
|
|
error: c31694_5
|
|
});
|
|
c31694_4 = true;
|
|
if (!c31694_4) {
|
|
break L14;
|
|
}
|
|
c9438_7.delete(c31694_1);
|
|
reportSoundFinishedPlaying(c31694_2, c31694_3);
|
|
break L14;
|
|
} catch (r94) {
|
|
r7 = r94;
|
|
c30650_3 = r94;
|
|
if (c30650_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
};
|
|
this._playSoundWithListener = function() {
|
|
return c20568_0.apply(this, arguments);
|
|
};
|
|
}
|
|
}
|
|
const soundboardManager = new SoundboardManager();
|
|
export default soundboardManager;
|