217 lines
5.3 KiB
TypeScript
217 lines
5.3 KiB
TypeScript
// Metro module 10275 (f10276).
|
|
import { NativeModules } from "react-native";
|
|
import { isMetaQuest } from "../../device/MetaQuestUtils.android";
|
|
import { isIOS } from "../../../utils/PlatformUtils";
|
|
let c6859_5;
|
|
let c6859_3 = 0;
|
|
class RNSound {
|
|
constructor(a0, a1, a2, a3) {
|
|
this._volume = a2;
|
|
this._loaded = false;
|
|
const _key = +c6859_3;
|
|
c6859_3 = _key + 1;
|
|
this._key = _key;
|
|
this._duration = -1;
|
|
this._numberOfChannels = -1;
|
|
this._volume = 1;
|
|
this._pan = 0;
|
|
this._numberOfLoops = 0;
|
|
this._sound = this._createSound(a0, a1, a3);
|
|
}
|
|
_createSound(a0, a1, c17824_0) {
|
|
NativeModules.DCDSoundManager.prepare(a0, a1, this._key, (a0, a1) => {
|
|
if (a1) {
|
|
this._duration = a1.duration;
|
|
this._numberOfChannels = a1.numberOfChannels;
|
|
}
|
|
if (a0 == null) {
|
|
this._loaded = true;
|
|
}
|
|
if (c17824_0 != null) {
|
|
c17824_0(a0);
|
|
}
|
|
});
|
|
}
|
|
play() {
|
|
if (this._loaded) {
|
|
NativeModules.DCDSoundManager.play(this._key);
|
|
}
|
|
}
|
|
pause() {
|
|
if (this._loaded) {
|
|
NativeModules.DCDSoundManager.pause(this._key);
|
|
}
|
|
}
|
|
stop() {
|
|
if (this._loaded) {
|
|
NativeModules.DCDSoundManager.stop(this._key);
|
|
}
|
|
}
|
|
release() {
|
|
if (this._loaded) {
|
|
NativeModules.DCDSoundManager.release(this._key);
|
|
}
|
|
this._loaded = false;
|
|
}
|
|
get volume() {
|
|
return this._volume;
|
|
}
|
|
set volume(a0) {
|
|
this._volume = a0;
|
|
if (this._loaded) {
|
|
NativeModules.DCDSoundManager.setVolume(this._key, a0);
|
|
}
|
|
}
|
|
get duration() {
|
|
return this._duration;
|
|
}
|
|
get numberOfLoops() {
|
|
return this._numberOfLoops;
|
|
}
|
|
set numberOfLoops(a0) {
|
|
this._numberOfLoops = a0;
|
|
if (this._loaded) {
|
|
NativeModules.DCDSoundManager.setNumberOfLoops(this._key, a0);
|
|
}
|
|
}
|
|
}
|
|
const r36 = {
|
|
NOTIFICATION: "notification",
|
|
VOICE: "voice",
|
|
RING_TONE: "ring_tone",
|
|
MEDIA: "media",
|
|
NOTIFICATION_NO_VIBRATION: "notification_no_vibration"
|
|
};
|
|
c6859_5 = {
|
|
call_calling: r36.VOICE,
|
|
call_ringing: isMetaQuest() ? r36.MEDIA : r36.RING_TONE,
|
|
call_ringing_halloween: isMetaQuest() ? r36.MEDIA : r36.RING_TONE,
|
|
camera_on: r36.VOICE,
|
|
camera_off: r36.VOICE,
|
|
deafen: r36.VOICE,
|
|
disconnect: r36.VOICE,
|
|
mention1: r36.NOTIFICATION,
|
|
mention2: r36.NOTIFICATION,
|
|
mention3: r36.NOTIFICATION,
|
|
message1: r36.NOTIFICATION,
|
|
message2: r36.NOTIFICATION,
|
|
message3: r36.NOTIFICATION,
|
|
mute: r36.VOICE,
|
|
ptt_start: r36.VOICE,
|
|
ptt_stop: r36.VOICE,
|
|
reconnect: r36.VOICE,
|
|
stage_waiting: r36.VOICE,
|
|
stream_ended: r36.VOICE,
|
|
stream_started: r36.VOICE,
|
|
stream_user_joined: r36.VOICE,
|
|
stream_user_left: r36.VOICE,
|
|
soundboard_sound: r36.VOICE,
|
|
undeafen: r36.VOICE,
|
|
unmute: r36.VOICE,
|
|
user_join: r36.VOICE,
|
|
user_leave: r36.VOICE,
|
|
user_moved: r36.VOICE,
|
|
vibing_wumpus: r36.MEDIA,
|
|
activity_end: r36.NOTIFICATION_NO_VIBRATION,
|
|
activity_launch: r36.NOTIFICATION_NO_VIBRATION,
|
|
activity_user_join: r36.NOTIFICATION_NO_VIBRATION,
|
|
activity_user_left: r36.NOTIFICATION_NO_VIBRATION
|
|
};
|
|
const r89 = class {
|
|
constructor(a0, a1, a2, a3) {
|
|
this.name = a0;
|
|
this.usage = c6859_5[a1];
|
|
this._volume = a2;
|
|
this.outputChannel = a3;
|
|
}
|
|
get volume() {
|
|
return this._volume;
|
|
}
|
|
set volume(a0) {
|
|
const volume2 = a0;
|
|
this._volume = a0;
|
|
this.ensureSound().then((result) => {
|
|
result.volume = volume2;
|
|
});
|
|
}
|
|
loop() {
|
|
this.ensureSound().then((result) => {
|
|
result.numberOfLoops = -1;
|
|
result.play();
|
|
});
|
|
}
|
|
play() {
|
|
this.ensureSound().then((result) => {
|
|
result.play();
|
|
});
|
|
}
|
|
playWithListener() {
|
|
return new Promise((c26642_0, c26642_1) => {
|
|
this.ensureSound().then((result) => {
|
|
if (!(result.duration != null && result.duration !== 0)) {
|
|
c26642_1("sound has no duration");
|
|
}
|
|
result.play();
|
|
setTimeout(() => {
|
|
c26642_0(true);
|
|
}, result.duration * (isIOS() ? 1000 : 1));
|
|
}).catch((error) => {
|
|
c26642_1(error);
|
|
});
|
|
});
|
|
}
|
|
pause() {
|
|
if (this.soundPromise != null) {
|
|
this.soundPromise.then((result) => result.pause());
|
|
}
|
|
}
|
|
stop() {
|
|
this.destroyAudio();
|
|
}
|
|
destroyAudio() {
|
|
if (this.soundPromise != null) {
|
|
this.soundPromise.then((result) => {
|
|
result.stop();
|
|
result.release();
|
|
this.soundPromise = null;
|
|
});
|
|
}
|
|
}
|
|
ensureSound() {
|
|
let soundPromise = this.soundPromise;
|
|
if (soundPromise == null) {
|
|
soundPromise = new Promise((c26643_0, c26643_1) => {
|
|
let c26643_2;
|
|
const name = this.name;
|
|
const usage = this.usage;
|
|
const _volume = this._volume;
|
|
const r18 = (a0) => {
|
|
if (a0 != null && a0 !== "") {
|
|
c26643_1(a0);
|
|
} else {
|
|
c26643_0(c26643_2);
|
|
}
|
|
};
|
|
const r20 = {
|
|
__proto__: RNSound.prototype
|
|
};
|
|
r20._volume = _volume;
|
|
r20._loaded = false;
|
|
const _key = +c6859_3;
|
|
c6859_3 = _key + 1;
|
|
r20._key = _key;
|
|
r20._duration = -1;
|
|
r20._numberOfChannels = -1;
|
|
r20._volume = 1;
|
|
r20._pan = 0;
|
|
r20._numberOfLoops = 0;
|
|
r20._sound = r20._createSound(name, usage, r18);
|
|
c26643_2 = r20;
|
|
});
|
|
}
|
|
this.soundPromise = soundPromise;
|
|
return this.soundPromise;
|
|
}
|
|
};
|
|
export { r89 as MobileAudioSound };
|