コンテンツにジャンプ

はじめから始める

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

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

ターミナル画面
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();

Get the native Capacitor plugin version.

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 がアップストリームで変更された場合に再度同期を実行してください。

「はじめから始める」から続けてください

「Getting Started」から続けて

あなたが「を使用している場合 Getting Started ダッシュボードとAPIの操作を計画するには、を接続してください native capabilityのために@capgo/capacitor-volume-buttonsを使用 Using @capgo/capacitor-volume-buttonsのnative capabilityの実装詳細 API Overview API Overviewの実装詳細 Introduction Introductionの実装詳細 API Keys API Keysの実装詳細 デバイス デバイスの実装詳細について