Lompat ke Konten

Membuka Awal

Jendela Terminal
bun add @capgo/capacitor-volume-buttons
bunx cap sync
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

API Ringkasan

Ringkasan API

Tetapkan untuk mendengar tekanan pada tombol volume perangkat keras.

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

Menghapus semua pemangku untuk plugin ini.

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
await VolumeButtons.removeAllListeners();

Dapatkan versi plugin native Capacitor.

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const { version } = await VolumeButtons.getPluginVersion();
console.log('Plugin version:', version);

Fungsi pendengar untuk peristiwa tombol volume.

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

Data peristiwa untuk tekan tombol volume.

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

Arah tekan tombol volume.

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

Halaman ini dihasilkan dari plugin’s src/definitions.ts. Re-run sinkronisasi ketika publik API berubah di atas.