跳过内容

开始入门

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

监听硬件音量按钮的按压。

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

标题:removeAllListeners

移除此插件的所有监听器。

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

标题:VolumeButtonListener

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

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

音量按钮按下事件数据

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

音量按钮按下方向

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

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

如果您正在使用 入门 为了计划仪表板和API操作,连接它与 使用@capgo/capacitor-volume-buttons 对于本地能力的使用@capgo/capacitor-volume-buttons API概述 对于API概述的实现细节 介绍 对于介绍的实现细节 API密钥 对于API密钥的实现细节 设备 设备详细信息的实现细节。