跳过内容

开始

GitHub

您可以使用我们的AI辅助设置来安装插件。使用以下命令将Capgo技能添加到您的AI工具中:

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

然后使用以下提示:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-volume-buttons` plugin in my project.

如果您更喜欢手动设置,请运行以下命令并按照以下平台特定的说明进行操作:

终端窗口
bun add @capgo/capacitor-volume-buttons
bunx cap sync
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

Listen for presses on the hardware 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();

Removes all listeners for this plugin.

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

VolumeButtonListener

音量按钮监听器

音量按钮事件监听函数

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

VolumeButtonPressed

音量按钮按下

音量按钮按下事件数据

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

VolumeButtonDirection

音量按钮方向

复制到剪贴板

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

音量按钮监听器

此页面是根据插件的

__CAPGO_KEEP_0__ src/definitions.ts重新同步时,公共的API发生了上游的变化。

如果您正在使用 开始 用于规划仪表板和API操作的 Using @capgo/capacitor-volume-buttons 使用@capgo/capacitor-volume-buttons 为使用@API/__CAPGO_KEEP_1__-volume-buttons的原生能力 API概述 为__CAPGO_KEEP_0__概述的实现细节 介绍 API 键值对 为 API 键值对的实现细节, 设备 为设备的实现细节,