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-volume-buttons`
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/volume-buttons/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-volume-buttonsbunx cap syncインポート
インポートのセクションimport { VolumeButtons } from '@capgo/capacitor-volume-buttons';API の概要
API の概要のセクションaddListener
addListenerのセクションハードウェアボリュームボタンの押下を検出する
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const listener = await VolumeButtons.addListener( 'volumeButtonPressed', (event) => { console.log(`Volume ${event.direction} button pressed`); });
// Remove listener when doneawait listener.remove();removeAllListeners
removeAllListenersのセクションこのプラグインのすべてのリスナーを削除する
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
await VolumeButtons.removeAllListeners();getPluginVersion
「getPluginVersion」のセクションCapacitorのネイティブプラグインバージョンを取得します。
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const { version } = await VolumeButtons.getPluginVersion();console.log('Plugin version:', version);型参照
「型参照」のセクションVolumeButtonListener
「VolumeButtonListener」のセクションボリュームボタンのイベントリスナー
export type VolumeButtonListener = (event: VolumeButtonPressed) => void;VolumeButtonPressed
「VolumeButtonPressed」のセクションボリュームボタン押下イベントデータ
export interface VolumeButtonPressed { /** Direction of the button press */ direction: VolumeButtonDirection;}VolumeButtonDirection
VolumeButtonDirectionのセクションボリュームボタンの押し方
export type VolumeButtonDirection = 'up' | 'down';真実の源
真実の源のセクションこのページはプラグインから生成されています。 src/definitions.tsパブリックAPIがアップストリームで変更された場合に再度Syncを実行してください。
Getting Startedから続けて
Getting Startedのセクションあなたが Getting Started ダッシュボードとAPIのオペレーションを計画する場合に使用している場合に、 Using @capgo/capacitor-volume-buttons for the native capability in Using @capgo/capacitor-volume-buttons API Overview for the implementation detail in API Overview Introduction for the implementation detail in Introduction API Keys for the implementation detail in API Keys, and Devices for the implementation detail in Devices.