__CAPGO_KEEP_2__

Getting Started

GitHub

CapgoのAIアシストセットアップを使用してプラグインをインストールできます。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] 範囲です。

録音中の実行中の視覚化に使用することを意図しています。 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();

クリップボードにコピーする

「Type Reference」

StartRecordingOptions

「StartRecordingOptions」

. により受け入れられるオプション

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

「StopRecordingResult」

. により返される結果

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

「GetRecordingStatusResult」

. により返される結果

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

GetCurrentAmplitudeResult

「GetCurrentAmplitudeResult」

. により返される結果

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;
}

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

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.ts.再度、パブリック API がアップストリームで変更されたときに、再度同期を実行してください。

あなたが使用している場合 Getting Started ネイティブメディアとインターフェイスの動作を計画するために使用している場合、接続してください。 ネイティブ機能のために@capgo/capacitor-audio-recorderを使用 Using @capgo/capacitor-audio-recorderでネイティブ機能を使用 Using @capgo/capacitor-live-activitiesでネイティブ機能を使用 Using @capgo/capacitor-live-activities @capgo/capacitor-live-activities 実装詳細については@capgo/capacitor-live-activitiesで確認してください。 Capacitorを使用して@capgo/capacitor-video-playerを実装します。 Capacitorを使用して@capgo/capacitor-video-playerを実装します。 Capacitorを使用して@capgo/capacitor-video-playerを実装します。 実装詳細については@capgo/capacitor-video-playerで確認してください。