본문으로 바로가기
플러그인으로 돌아가기
@capgo/native-audio
튜토리얼
github.com/Cap-go에서 github

네이티브 오디오

게임 및 앱에서 낮은 지연 시간으로 작동하는 네이티브 오디오 엔진을 사용하여 짧은 오디오 파일을 재생합니다.

가이드

자연 음성 튜토리얼

Using @capgo/native-audio

자연 음성 엔진을 위한 네이티브 플러그인입니다.

설치

bun add @capgo/native-audio
bunx cap sync

이 플러그인이 제공하는 기능

  • configure - 오디오 플레이어를 구성합니다.
  • preload - 오디오 파일을 로드합니다.
  • playOnce - 오디오 파일을 자동으로 정리하는 한 번의 오디오 재생입니다.
  • isPreloaded - 오디오 파일이 미리 로드되었는지 확인합니다.

예시 사용

configure

오디오 플레이어를 구성합니다.

import { NativeAudio } from '@capgo/native-audio';

await NativeAudio.configure({} as ConfigureOptions);

preload

오디오 파일을 로드합니다.

import { NativeAudio } from '@capgo/native-audio';

await NativeAudio.preload({} as PreloadOptions);

playOnce

자동으로 청소되는 오디오 파일을 한 번 재생합니다.

import { NativeAudio } from '@capgo/native-audio';

// Simple one-shot playback
await NativeAudio.playOnce({ assetPath: 'audio/notification.mp3' });

// Play and delete the file after completion
await NativeAudio.playOnce({
  assetPath: 'file:///path/to/temp/audio.mp3',
  isUrl: true,
  deleteAfterPlay: true
});

// Get the assetId to control playback
const { assetId } = await NativeAudio.playOnce({
  assetPath: 'audio/long-track.mp3',
  autoPlay: true
});
// Later, you can stop it manually if needed
await NativeAudio.stop({ assetId });

isPreloaded

오디오 파일이 미리 로드되었는지 확인합니다.

import { NativeAudio } from '@capgo/native-audio';

await NativeAudio.isPreloaded({} as PreloadOptions);

전체 참조