Using @capgo/capacitor-flash
Capacitor Flash プラグイン (デバイスのフラッシュライト/トーチを制御する)
インストール
bun add @capgo/capacitor-flash
bunx cap sync
このプラグインが公開するもの
isAvailable- デバイスでフラッシュライトが利用可能かどうかを確認するswitchOn- フラッシュライトをオンにするswitchOff- フラッシュライトをオフにするisSwitchedOn- フラッシュライトが現在オンかオフかを確認する
使用例
isAvailable
デバイスでフラッシュライトが利用可能かどうかを確認する
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isAvailable();
if (value) {
console.log('Flashlight is available');
}
switchOn
点灯します。
import { CapacitorFlash } from '@capgo/capacitor-flash';
// Turn on at full brightness
await CapacitorFlash.switchOn({ intensity: 1.0 });
// Turn on at half brightness
await CapacitorFlash.switchOn({ intensity: 0.5 });
switchOff
点灯を消します。
import { CapacitorFlash } from '@capgo/capacitor-flash';
await CapacitorFlash.switchOff();
isSwitchedOn
点灯がオンかオフかを確認します。
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isSwitchedOn();
console.log('Flashlight is on:', value);
フルリファレンス
- GitHub: https://github.com/Cap-go/capacitor-flash/
- ドキュメント: /docs/plugins/flash/
Keep going from Using @capgo/capacitor-flash
Capacitor Flashを使用している場合 Using @capgo/capacitor-flash to plan dashboard and API operations, connect it with @capgo/capacitor-flash for the implementation detail in @capgo/capacitor-flash, Getting Started Capacitor-Flash用の実装詳細については API Overview for the implementation detail in API Overview, Capacitor-Flashの導入 Capacitor-Flash用の実装詳細についてはCapacitor-Flashのキー API Keys for the implementation detail in API Keys.