メインコンテンツにジャンプ
プラグインに戻る
@capgo/capacitor-ボリュームボタンのボリュームボタン
チュートリアル
@capgo/capacitor-ボリュームボタンのボリュームボタン

ボリュームボタン

ハードウェアボリュームボタンの押下をキャプチャしてカスタムアプリのコントロールやショートカットを作成

ガイド

ボリュームボタンのチュートリアル

@capgo/capacitor-ボリュームボタンの使用

Capacitor Volume Buttons Plugin for detecting hardware volume button presses.

インストール

bun add @capgo/capacitor-volume-buttons
bunx cap sync

このプラグインが公開するもの

  • 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);

完全なリファレンス

@capgo/capacitor-volume-buttons

使用中 @capgo/capacitor-volume-buttons native プラグインの作業を計画する場合、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-volume-buttons @capgo/capacitor-volume-buttons @capgo/capacitor-volume-buttons の実装詳細については、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-volume-buttons を参照してください。 Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and プラグインの追加または更新 __CAPGO_KEEP_0__の実装詳細について