メニューに進む

Getting Started

ターミナルウィンドウ
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-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.