Guide
ボリュームボタンのチュートリアル
ボリュームボタンを使用するには@capgo/capacitor-volume-buttons
Capacitorボリュームボタンプラグイン
インストール
bun add @capgo/capacitor-volume-buttons
bunx cap sync
__CAPGO_KEEP_0__ボリュームボタンプラグインの概要
addListener-ハードウェアボリュームボタンを押したときにリスナーを実行します。removeAllListeners-このプラグインのリスナーをすべて削除します。getPluginVersion-Capacitorプラグインのネイティブバージョンを取得します。
使用例
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 done
await listener.remove();
removeAllListeners
このプラグインのすべてのリスナーを削除
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
await VolumeButtons.removeAllListeners();
getPluginVersion
Capacitorのネイティブプラグインバージョンを取得
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const { version } = await VolumeButtons.getPluginVersion();
console.log('Plugin version:', version);
フルリファレンス
- GitHub: https://github.com/Cap-go/capacitor-ボリュームボタン/
- ドキュメント: /docs/plugins/volume-buttons/