Getting Started
このプラグインのインストールステップとフルマークダウンガイドのコピー可能な設定プロンプトをコピーする。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-audio-session`, `@capgo/capacitor-audiosession`
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/audiosession/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.
Install
「Install」セクションCapgoの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-session` plugin in my project.Manualセットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-audio-sessionbunx cap syncimport { AudioSession } from '@capgo/capacitor-audio-session';API Overview
Section titled “API Overview”currentOutputs
Section titled “現在の出力”現在のアクティブなオーディオ出力ルートを取得します。
ウェブと非iOSプラットフォームでは、空の配列に解決されます。
import { AudioSession } from '@capgo/capacitor-audio-session';
await AudioSession.currentOutputs();overrideOutput
Section titled “出力のオーバーライド”現在のオーディオ出力ルートをオーバーライドします。
Use speaker を使用して、ビルトインスピーカーを通じて再生することを強制します。
default __CAPGO_KEEP_0__をシステムで選択されたルートに戻します。
import { AudioSession } from '@capgo/capacitor-audio-session';
await AudioSession.overrideOutput({} as OutputOverrideType);型の参照
「型の参照」のセクションAudioSessionPorts
「オーディオセッションポート」のセクションiOSで利用可能なオーディオ出力ルート
export enum AudioSessionPorts { AIR_PLAY = 'airplay', BLUETOOTH_LE = 'bluetooth-le', BLUETOOTH_HFP = 'bluetooth-hfp', BLUETOOTH_A2DP = 'bluetooth-a2dp', BUILT_IN_SPEAKER = 'builtin-speaker', BUILT_IN_RECEIVER = 'builtin-receiver', HDMI = 'hdmi', HEADPHONES = 'headphones', LINE_OUT = 'line-out',}OutputOverrideType
「出力オーバーライドタイプ」のセクション出力オーバーライドタイプ defaultシステムで選択されたルートを使用します。 speakerシステムで選択されたルートを強制します。
export type OutputOverrideType = 'default' | 'speaker';OverrideResult
OverrideResultのセクション出力オーバーライド要求の結果。
export type OverrideResult = { success: boolean; message: string;};RouteChangeListener
RouteChangeListenerのセクションオーディオルートが変更されたときに呼び出されるリスナー。
export type RouteChangeListener = (reason: RouteChangeReasons) => void;InterruptionListener
InterruptionListenerのセクションオーディオセッションが中断されたり終了したときに呼び出されるリスナー。
export type InterruptionListener = (type: InterruptionTypes) => void;RouteChangeReasons
RouteChangeReasonsのセクションexport enum RouteChangeReasons { NEW_DEVICE_AVAILABLE = 'new-device-available', OLD_DEVICE_UNAVAILABLE = 'old-device-unavailable', CATEGORY_CHANGE = 'category-change', OVERRIDE = 'override', WAKE_FROM_SLEEP = 'wake-from-sleep', NO_SUITABLE_ROUTE_FOR_CATEGORY = 'no-suitable-route-for-category', ROUTE_CONFIGURATION_CHANGE = 'route-config-change', UNKNOWN = 'unknown',}InterruptionTypes
InterruptionTypesのセクションexport enum InterruptionTypes { BEGAN = 'began', ENDED = 'ended',}真実の源
「真実の源」というセクションこのページはプラグインの src/definitions.tsパブリック API がアップストリームで変更された場合に再度同步を実行してください。
Getting Started から続けて
「Getting Started から続けて」というセクションあなたが Getting Started ネイティブメディアとインターフェイスの動作を計画する場合、 Using @capgo/capacitor-audio-session Using @capgo/capacitor-audio-session @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, @capgo/capacitor-live-activities for the native capability in Using @capgo/capacitor-video-player, and @capgo/capacitor-live-activities for the implementation detail in @capgo/capacitor-video-player.