コンテンツにスキップ

始め方

GitHub

インストール

インストール

AI-Assisted セットアップを使用してプラグインをインストールすることができます。AI ツールに Capgo スキルを追加するには、以下のコマンドを実行してください。

ターミナル
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用してください。

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-audio-recorder` plugin in my project.

Manual Setup を使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。

ターミナル
bun add @capgo/capacitor-audio-recorder
bunx cap sync

インポート

インポート
import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';

デバイスマイクを使用してオーディオを記録します。

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.startRecording();

Android (API 24+)、iOS、Web でのみ利用可能な場合にのみ、進行中の記録を停止します。

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.pauseRecording();

前回の記録を再開します。

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.resumeRecording();

現在の録音を停止し、記録された音を保存します。

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.stopRecording();

現在の録音をキャンセルし、キャプチャされた音を破棄します。

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.cancelRecording();

現在の録音の状態を取得します。

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.getRecordingStatus();

現在の入力振幅(マイクのレベル)を、指定された範囲内の正規化された数値として取得します。 [0, 1] クリップボードにコピー

録音中のライブビジュアライゼーション、VUメーターまたは波形などに使用することを意図しています。 レコーディングが行われていない場合に返します。 UIレートのポーリングに設計されています。 波形の場合、60-100msの間隔が良くてはなりません。 それを緊急ループで呼び出すのは避けるべきです。 それぞれの呼び出しはJSとネイティブの橋を渡ります。 0 __CAPGO_KEEP_0__

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.getCurrentAmplitude();

マイクへのアクセス権の現在の状態を返します。

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.checkPermissions();

マイクへのアクセス権を求めます。

import { CapacitorAudioRecorder } from '@capgo/capacitor-audio-recorder';
await CapacitorAudioRecorder.requestPermissions();

__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_2__

__CAPGO_KEEP_3__

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_4__

__CAPGO_KEEP_3__

export interface GetRecordingStatusResult {
/**
* The current recording status.
*
* @since 1.0.0
*/
status: RecordingStatus;
}

GetCurrentAmplitudeResult

__CAPGO_KEEP_5__

__CAPGO_KEEP_3__

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

__CAPGO_KEEP_6__

とによって返される許可情報。

export interface PermissionStatus {
/**
* The permission state for audio recording.
*
* @since 1.0.0
*/
recordAudio: PermissionState;
}

レコーディング中にエラーが発生したときに発生するイベント。

export interface RecordingErrorEvent {
/**
* The error message.
*
* @since 1.0.0
*/
message: string;
}

レコーディングが完了したときに発生するイベント。

export type RecordingStoppedEvent = StopRecordingResult;

iOSで利用可能なオーディオセッションカテゴリオプション。

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',
}

iOS上で利用可能なオーディオセッションモード

export enum AudioSessionMode {
Default = 'DEFAULT',
GameChat = 'GAME_CHAT',
Measurement = 'MEASUREMENT',
SpokenAudio = 'SPOKEN_AUDIO',
VideoChat = 'VIDEO_CHAT',
VideoRecording = 'VIDEO_RECORDING',
VoiceChat = 'VOICE_CHAT',
}

レコーディングステータス

export enum RecordingStatus {
Inactive = 'INACTIVE',
Recording = 'RECORDING',
Paused = 'PAUSED',
}

Capacitorによってサポートされるプラットフォームパーミッションステート

export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';

「ソースオブトゥルスの」

「ソースオブトゥルスの」セクション

このページはプラグインの src/definitions.tsAPIの公開変更がアップストリームで発生した場合に再度同期を実行してください

あなたが「を使用している場合 はじめから ネイティブメディアとインターフェイスの動作を計画するには、を接続します Using @capgo/capacitor-audio-recorder for the native capability in Using @capgo/capacitor-audio-recorder, Using @capgo/capacitor-live-activities for the native capability in Using @capgo/capacitor-live-activities, @capgo/capacitor-live-activities for the implementation detail in @capgo/capacitor-live-activities, Using @capgo/capacitor-video-player native capabilityを使用するために@capgo/capacitor-video-playerを使用し、 @capgo/capacitor-video-player native capabilityの実装詳細を@capgo/capacitor-video-playerで確認する。