メインコンテンツにジャンプ

はじめに

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

APIの概要

APIの概要

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

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

__CAPGO_KEEP_0__の型参照

クリップボードにコピー

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

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

VolumeButtonPressed

バツルムボタン押下

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

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

クリップボードにコピー

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

This page is generated from the plugin’s src/definitions.ts. upstream の 公開 API が変更されたときに、再度 同期を実行してください。