はじめから
このプラグインのセットアッププロンプトをコピーします。インストール手順とフルマークダウンガイドが含まれます。
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.
インストール
「インストール」のセクション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 Setup を使用する場合は、以下のコマンドを実行してください。プラットフォーム固有の指示は下記を参照してください。
bun add @capgo/capacitor-audio-sessionbunx cap syncImport
「Import」セクションimport { AudioSession } from '@capgo/capacitor-audio-session';API の概要セクション
Section titled “API Overview”currentOutputs
現在のアクティブなオーディオ出力ルートを取得します。Copy to clipboard
ウェブと非iOSプラットフォームでは、この値は空の配列に解決されます。
import { AudioSession } from '@capgo/capacitor-audio-session';
await AudioSession.currentOutputs();overrideOutput
Section titled “overrideOutput”Override the current audio output route.
Use speaker to force playback through the built-in speaker, or
default to restore the system-selected route.
import { AudioSession } from '@capgo/capacitor-audio-session';
await AudioSession.overrideOutput({} as OutputOverrideType);Type Reference
Section titled “Type Reference”AudioSessionPorts
Section titled “AudioSessionPorts”Available audio output routes on 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
「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
Section titled “中断リスナー”リスナーは、音声セッションが中断されたり終了したときに呼び出されます。
export type InterruptionListener = (type: InterruptionTypes) => void;RouteChangeReasons
Section titled “ルート変更の理由”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
Section titled “中断の種類”export enum InterruptionTypes { BEGAN = 'began', ENDED = 'ended',}このページはプラグインの src/definitions.tsパブリック API がアップストリームで変更されたときに、再度同期を実行してください。
Getting Started から続けてください
「Getting Started」から続けてくださいあなたが使用している Getting Started ネイティブメディアとインターフェイスの動作を計画するには 「@capgo/capacitor-audio-session」を使用 「@capgo/capacitor-audio-session」を使用してネイティブ機能を接続 「@capgo/capacitor-live-activities」を使用 「@capgo/capacitor-live-activities」を使用してネイティブ機能を接続 「@capgo/capacitor-live-activities」 「@capgo/capacitor-live-activities」の実装詳細 「@capgo/capacitor-video-player」を使用 「@capgo/capacitor-video-player」を使用してネイティブ機能を接続 @capgo/capacitor-video-player for the implementation detail in @capgo/capacitor-video-player.