跳过内容

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

VolumeButtonListener

标题:音量按钮监听器

音量按钮事件的监听函数。

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

VolumeButtonPressed

VolumeButtonPressed标题

音量按钮按下事件数据

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

VolumeButtonDirection

VolumeButtonDirection标题

音量按钮按下方向

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

真实数据来源

真实数据来源标题

此页面由插件生成 src/definitions.ts. 当公共API上游更改时,请重新运行同步

从开始就继续

从开始就继续标题

If you are using __CAPGO_KEEP_0__ in __CAPGO_KEEP_1__ Getting Started 为 API 的 __CAPGO_KEEP_1__ 使用 @capgo/capacitor-volume-buttons 使用 @capgo/capacitor-volume-buttons 的原生功能 API 简介 API 的实现细节 简介 __CAPGO_KEEP_0__ 的实现细节 API 的密钥 API 的实现细节 设备 __CAPGO_KEEP_0__