メインコンテンツにジャンプ
@capgo/capacitor-ボリュームボタン デバイスAPI オープンソース

ボリュームボタン Capacitor プラグイン

ハードウェアボリュームボタンを押したときにカスタムアプリのコントロールやショートカットをキャプチャする

インストール

bun add @capgo/capacitor-volume-buttons bunx cap sync
npm、pnpmまたはyarn
  • npm install @capgo/capacitor-volume-buttons
  • pnpm add @capgo/capacitor-volume-buttons
  • yarn add @capgo/capacitor-volume-buttons

ガイド

Capacitor でボリュームボタンを使用する方法

デバイスでテスト

Capgoアプリをダウンロードし、QRコードをスキャンしてください。code

ボリュームボタン プラグインのプレビュー QRコードcode

@capgo/capacitor-ボリュームボタン

ボリュームボタン プラグイン(Capacitor)を使用してハードウェア ボリュームボタン押下を検出します。

インストール

bun add @capgo/capacitor-volume-buttons
bunx cap sync

bunx cap sync プラグインのネイティブ code をプロジェクトにコピーします。プラグインのアップグレード後は再度実行してください。

インポート

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

APIの概要

方法 説明
addListener ハードウェアボリュームボタンの押下を検知する
removeAllListeners このプラグインのすべてのリスナーを削除
getPluginVersion ネイティブCapacitorプラグインのバージョンを取得

例

addListener()

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

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

このプラグインのすべてのリスナーを削除

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

await VolumeButtons.removeAllListeners();

getPluginVersion()

ネイティブCapacitorプラグインのバージョンを取得

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

const { version } = await VolumeButtons.getPluginVersion();
console.log('Plugin version:', version);

context

addListener ハンドルを返します。呼び出す handle.remove() 画面がアンマウントされたとき、または VolumeButtons.removeAllListeners() リスナーをすべてクリアするときに呼び出す。

フルリファレンス

使用中の @capgo/capacitor-volume-buttons から続けて

あなたが使用している 使用中の @capgo/capacitor-volume-buttons native plugin work を計画するには、を接続する @capgo/capacitor-ボリュームボタン Capacitor の @capgo/capacitor-volume-buttons の実装詳細については スタートガイド Capacitor の実装詳細については Capgo プラグインディレクトリ for the product workflow in Capgo Plugin Directory, Capacitor プラグインは Capgo によって提供されています。 for Capacitor の実装詳細については、Capgo によって提供されるプラグインです。 プラグインの追加または更新 プラグインの追加または更新の実装詳細については

FAQ

ボリュームボタンのプラグインFAQ

Capacitor ボリュームボタンプラグインを Capacitor アプリにインストールするにはどうすればよいですか。

Run "bun add @capgo/capacitor-volume-buttons" (or "npm install @capgo/capacitor-volume-buttons"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-volume-buttons" in your app code.

@capgo/capacitor-volume-buttonsは、React、Vue、Angularとどのくらいの関係があるのでしょうか。

Yes. Volume Buttons is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

どのCapacitorバージョンが@capgo/capacitor-volume-buttonsをサポートしていますか?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

は@capgo/capacitor-volume-buttons無料でオープンソースですか?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-volume-buttons/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Volume Buttonsを使用するcodeをアップデートすることは可能ですか?

プラグインをインストールまたはアップグレードすると、ネイティブcodeが変更されるため、ストアのビルドが必要になります。その後、JavaScript、HTML、CSSの変更がプラグインを呼び出すと、Capgoのライブアップデートで即時配信できます。

Ship Volume Buttonsの変更を待たずにアプリのレビューを待たずに

プラグインがストアに追加されたら、Capgoライブアップデートは、ユーザーにJavaScript、HTML、CSSの変更を数分でプッシュします

始めましょう Capgo