メニューに進む

Getting Started

GitHub

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-volume-buttons` plugin in my project.

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

ターミナルウィンドウ
bun add @capgo/capacitor-volume-buttons
bunx cap sync
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

ハードウェアボリュームボタンの押下を検出する

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const listener = await VolumeButtons.addListener(
'volumeButtonPressed',
(event) => {
console.log(`Volume ${event.direction} button pressed`);
}
);
// Remove listener when done
await listener.remove();

このプラグインのすべてのリスナーを削除する

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
await VolumeButtons.removeAllListeners();

Capacitorのネイティブプラグインバージョンを取得します。

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const { version } = await VolumeButtons.getPluginVersion();
console.log('Plugin version:', version);

ボリュームボタンのイベントリスナー

export type VolumeButtonListener = (event: VolumeButtonPressed) => void;

ボリュームボタン押下イベントデータ

export interface VolumeButtonPressed {
/** Direction of the button press */
direction: VolumeButtonDirection;
}

ボリュームボタンの押し方

export type VolumeButtonDirection = 'up' | 'down';

このページはプラグインから生成されています。 src/definitions.tsパブリックAPIがアップストリームで変更された場合に再度Syncを実行してください。

Getting Startedから続けてください

Getting Startedのセクション

あなたが Getting Started ダッシュボードとAPIの作業を計画する場合に使用している場合に接続してください Using @capgo/capacitor-ボリュームボタン for the native capability in Using @capgo/capacitor-ボリュームボタン, API の概要 for the implementation detail in API の概要, 導入 for the implementation detail in導入, API のキー for the implementation detail in API のキー, と デバイス for the implementation detail in デバイス。