From 0ab37defb4f8f6fa55238f0d07eb536ea6d02deb Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 31 Aug 2026 23:18:02 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Drop=20the=20fetch-based=20click?= =?UTF-8?q?=20sound=20loader=20in=20the=20expo=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SDK 56 made expo/fetch the default global fetch, and getClickSound reached for a local asset URI via `fetch(asset.uri).arrayBuffer()` — a path expo does not document as supported for file:// under the new implementation. audio-api 0.13's decodeAudioData takes `number | string | ArrayBuffer`, so it accepts the Metro asset module id straight from require() and does its own decoding natively. That removes the fetch, the ArrayBuffer round-trip and the helper altogether rather than working around the change. The example-bare copy is untouched: it reads via react-native-fs, so the expo/fetch swap never applied to it. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_014JJ2weaFu4jhu2XirMkbWe --- examples/example-expo/App.tsx | 6 +++--- examples/example-expo/utils/getClickSound.ts | 20 -------------------- 2 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 examples/example-expo/utils/getClickSound.ts diff --git a/examples/example-expo/App.tsx b/examples/example-expo/App.tsx index 39ca9d3..550592c 100644 --- a/examples/example-expo/App.tsx +++ b/examples/example-expo/App.tsx @@ -19,7 +19,6 @@ import type { NativeScrollEvent, NativeSyntheticEvent } from "react-native"; import { TimerPicker, TimerPickerModal } from "../../src"; import { CustomButton } from "./components/CustomButton"; import { formatTime } from "./utils/formatTime"; -// import { getClickSound } from "./utils/getClickSound"; export default function App() { const scrollViewRef = useRef(null); @@ -44,8 +43,9 @@ export default function App() { // const setupAudio = async () => { // try { // const context = new AudioContext(); - // const arrayBuffer = await getClickSound(); - // const buffer = await context.decodeAudioData(arrayBuffer); + // const buffer = await context.decodeAudioData( + // require("./assets/select_click.mp3") + // ); // audioContextRef.current = context; // audioBufferRef.current = buffer; diff --git a/examples/example-expo/utils/getClickSound.ts b/examples/example-expo/utils/getClickSound.ts deleted file mode 100644 index 6f0bc13..0000000 --- a/examples/example-expo/utils/getClickSound.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Asset } from "expo-asset"; - -/** - * Loads and returns the click sound effect as an ArrayBuffer. - * This function loads a sound file from the assets directory and converts it to an ArrayBuffer - * that can be used for audio playback. - * - * @returns {Promise} A promise that resolves to the sound file as an ArrayBuffer - * @throws {Error} If the asset fails to load or if the fetch request fails - * - * @example - * const clickSound = await getClickSound(); - * // Use clickSound with Audio API or other audio playback methods - */ -export const getClickSound = async () => { - const [asset] = await Asset.loadAsync(require("../assets/select_click.mp3")); - - const response = await fetch(asset.uri); - return await response.arrayBuffer(); -};