From 363f9984f62e3af80be962198a5b6ba24c202690 Mon Sep 17 00:00:00 2001 From: OTKUSteyler Date: Fri, 11 Sep 2026 07:58:22 +0200 Subject: [PATCH] Delete src/core/plugins/custom background music directory --- .../custom background music/Settings.tsx | 33 ---------- .../plugins/custom background music/index.ts | 65 ------------------- 2 files changed, 98 deletions(-) delete mode 100644 src/core/plugins/custom background music/Settings.tsx delete mode 100644 src/core/plugins/custom background music/index.ts diff --git a/src/core/plugins/custom background music/Settings.tsx b/src/core/plugins/custom background music/Settings.tsx deleted file mode 100644 index 79872bb..0000000 --- a/src/core/plugins/custom background music/Settings.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { storage } from "@vendetta/plugin"; -import { useProxy } from "@vendetta/storage"; -import { getAssetIDByName } from "@vendetta/ui/assets"; -import { Forms, General } from "@vendetta/ui/components"; -import { settings, playFromUrl } from "."; - -const { FormSection, FormRow, FormIcon, FormInput } = Forms; - -export default function Settings() { - useProxy(storage); - - return ( - - - } - /> - { - settings.url = x; - if (x) playFromUrl(x); - }} - style={{ marginTop: -25, marginHorizontal: 12 }} - /> - - - ); -} diff --git a/src/core/plugins/custom background music/index.ts b/src/core/plugins/custom background music/index.ts deleted file mode 100644 index 76f5ce5..0000000 --- a/src/core/plugins/custom background music/index.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { findByProps } from "@vendetta/metro"; -import { ReactNative } from "@vendetta/metro/common"; -import { storage } from "@vendetta/plugin"; -import Settings from "./Settings"; -import { defineCorePlugin } from ".."; - -const { DCDSoundManager } = ReactNative.NativeModules; - -export const settings: { url?: string } = storage; - -const SOUND_ID = 6973; - -let isPlaying = false; -let loopTimeoutId: ReturnType | null = null; -let currentUrl: string | null = null; - -function prepareSound(url: string): Promise { - return new Promise((resolve) => { - DCDSoundManager.prepare(url, "music", SOUND_ID, (error: any, sound: any) => { - if (error) return resolve(-1); - resolve(sound?.duration ?? -1); - }); - }); -} - -function stopLoop() { - isPlaying = false; - if (loopTimeoutId) { - clearTimeout(loopTimeoutId); - loopTimeoutId = null; - } - DCDSoundManager.stop(SOUND_ID); -} - -// Exported so Settings.tsx can call this the moment the URL changes -export async function playFromUrl(url: string) { - if (!url) return; - - stopLoop(); - currentUrl = url; - - const duration = await prepareSound(url); - if (duration === -1 || currentUrl !== url) return; - - isPlaying = true; - - const cycle = async () => { - if (!isPlaying || currentUrl !== url) return; - await DCDSoundManager.play(SOUND_ID); - loopTimeoutId = setTimeout(cycle, duration); - }; - - cycle(); -} - -export default { - onLoad: () => { - if (settings.url) playFromUrl(settings.url); - }, - onUnload: () => { - stopLoop(); - currentUrl = null; - }, - settings: Settings, -};