はじめに
このプラグインのインストール手順とフルマークダウンガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-audio-recorder`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/audio-recorder/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」のセクションbun add @capgo/capacitor-audio-recorderbunx cap syncインポート
「インポート」セクションimport { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';API オーバービュー
「API オーバービュー」セクションstartRecording
「startRecording」セクションデバイスマイクを使用して音声の録音を開始します。
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.startRecording();pauseRecording
「pauseRecording」セクション進行中の録音を一時停止します。Android (API 24+)、iOS、Webで利用可能です。
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.pauseRecording();resumeRecording
「resumeRecording」セクション再生を一時停止した場合に、再開する。
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.resumeRecording();stopRecording
「stopRecording」セクション現在の録音を停止し、記録された音を保存します。
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.stopRecording();cancelRecording
「cancelRecording」セクション現在の録音をキャンセルし、キャプチャされた音を破棄します。
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.cancelRecording();getRecordingStatus
「getRecordingStatus」セクション現在の録音の状態を取得します。
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.getRecordingStatus();getCurrentAmplitude
「getCurrentAmplitude」セクション現在の入力振幅(マイクレベル)を、範囲内の正規化された数値として取得します。 [0, 1] 範囲。
録音中のライブビジュアライゼーション(VUメーターや波形)をドライブするために設計されています。録音が行われていない場合に返されます。UIレートのポーリングに適しています。波形の場合、60-100msの間隔が良く始まるポイントです。緊急ループ内で呼び出すのを避けましょう。各呼び出しはJS/ネイティブブリッジを渡ります。 0 クリップボードにコピー
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.getCurrentAmplitude();checkPermissions
マイクへのアクセス権の現在の状態を取得します。クリップボードにコピー
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.checkPermissions();requestPermissions
マイクへのアクセス許可を求めます。クリップボードにコピー
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.requestPermissions();__CAPGO_KEEP_0__
種類の参照StartRecordingOptions
レコーディングの開始オプション__CAPGO_KEEP_0__を受け入れるオプション
export interface StartRecordingOptions { /** * The audio session category options for recording. Only available on iOS. * * @since 1.0.0 */ audioSessionCategoryOptions?: AudioSessionCategoryOption[];
/** * The audio session mode for recording. Only available on iOS. * * @since 1.0.0 */ audioSessionMode?: AudioSessionMode;
/** * The audio bit rate in bytes per second. * Only available on Android and iOS. * * @since 1.0.0 */ bitRate?: number;
/** * The audio sample rate in Hz. * Only available on Android and iOS. * * @since 1.0.0 */ sampleRate?: number;}StopRecordingResult
レコーディングの停止結果__CAPGO_KEEP_0__によって返される結果
export interface StopRecordingResult { /** * The recorded audio as a Blob. Only available on Web. * * @since 1.0.0 */ blob?: Blob;
/** * The duration of the recording in milliseconds. * * @since 1.0.0 */ duration?: number;
/** * The URI pointing to the recorded file. Only available on Android and iOS. * * @since 1.0.0 */ uri?: string;}GetRecordingStatusResult
レコーディングのステータス取得結果__CAPGO_KEEP_0__によって返される結果
export interface GetRecordingStatusResult { /** * The current recording status. * * @since 1.0.0 */ status: RecordingStatus;}GetCurrentAmplitudeResult
現在の振幅の取得結果__CAPGO_KEEP_0__によって返される結果
export interface GetCurrentAmplitudeResult { /** * The current input amplitude normalized to the `[0, 1]` range, where `0` * represents silence and `1` represents the maximum level the platform can * report. The value is `0` when no recording is active. * * Note: the source signal differs between platforms — Android reports the * peak sample amplitude since the last call, iOS reports the average power * in dB converted to linear, and Web reports the RMS of the latest frame. * Consumers that need cross-platform parity may want to apply a * per-platform scaling curve. * * @since 8.1.0 */ value: number;}PermissionStatus
許可状態のセクションとによって返される許可情報。
export interface PermissionStatus { /** * The permission state for audio recording. * * @since 1.0.0 */ recordAudio: PermissionState;}RecordingErrorEvent
レコーディングエラーイベントのセクションレコーディング中にエラーが発生したときに発生するイベント。
export interface RecordingErrorEvent { /** * The error message. * * @since 1.0.0 */ message: string;}RecordingStoppedEvent
レコーディングが完了したときに発生するイベント。クリップボードにコピー
export type RecordingStoppedEvent = StopRecordingResult;AudioSessionCategoryOption
クリップボードにコピー__CAPGO_KEEP_0__
export enum AudioSessionCategoryOption { AllowAirPlay = 'ALLOW_AIR_PLAY', AllowBluetooth = 'ALLOW_BLUETOOTH', AllowBluetoothA2DP = 'ALLOW_BLUETOOTH_A2DP', DefaultToSpeaker = 'DEFAULT_TO_SPEAKER', DuckOthers = 'DUCK_OTHERS', InterruptSpokenAudioAndMixWithOthers = 'INTERRUPT_SPOKEN_AUDIO_AND_MIX_WITH_OTHERS', MixWithOthers = 'MIX_WITH_OTHERS', OverrideMutedMicrophoneInterruption = 'OVERRIDE_MUTED_MICROPHONE_INTERRUPTION',}AudioSessionMode
「オーディオセッションモード」のセクションiOSで利用可能なオーディオセッションモード
export enum AudioSessionMode { Default = 'DEFAULT', GameChat = 'GAME_CHAT', Measurement = 'MEASUREMENT', SpokenAudio = 'SPOKEN_AUDIO', VideoChat = 'VIDEO_CHAT', VideoRecording = 'VIDEO_RECORDING', VoiceChat = 'VOICE_CHAT',}RecordingStatus
「レコーディングステータス」のセクションレコーディングステータス
export enum RecordingStatus { Inactive = 'INACTIVE', Recording = 'RECORDING', Paused = 'PAUSED',}PermissionState
「パーミッションステート」のセクションCapacitorがサポートするプラットフォームパーミッションステート
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';「真実の源」のセクション
Copy to clipboardプラグインから生成されたページは src/definitions.tspublic API がアップストリームで変更された場合に、再度同期を実行してください。