MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / audioBufferSpace

Function audioBufferSpace

src/engine/assets.ts:219–243  ·  view source on GitHub ↗
(engine: VisualNovelEngine)

Source from the content-addressed store, hash-verified

217// ============================================================================
218
219export async function audioBufferSpace(engine: VisualNovelEngine): Promise<Space | null> {
220 // If we already know IndexedDB isn't available, skip
221 if (engine._indexedDBAvailable === false) {
222 return null;
223 }
224
225 if (!engine._audioBufferSpace) {
226 try {
227 engine._audioBufferSpace = new Space(SpaceAdapter.IndexedDB, {
228 name: `${Text.friendly(engine.setting('Name') as string)}_AudioCache`,
229 version: '1',
230 store: 'decodedAudio'
231 } as ConstructorParameters<typeof Space>[1]);
232
233 await engine._audioBufferSpace.open();
234 engine._indexedDBAvailable = true;
235 } catch (error) {
236 console.warn('IndexedDB not available for audio caching. Audio will still work but won\'t persist across sessions:', error);
237 engine._indexedDBAvailable = false;
238 return null;
239 }
240 }
241
242 return engine._audioBufferSpace;
243}
244
245export function isIndexedDBAvailable(engine: VisualNovelEngine): boolean | null {
246 return engine._indexedDBAvailable;

Callers 4

getAudioBufferPersistentFunction · 0.85

Calls 2

settingMethod · 0.80
openMethod · 0.65

Tested by

no test coverage detected