パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.1.0

flutter_headset_detector

ヘッドセットイベント用のFlutterプラグイン。ヘッドセットが差し込まれたか、外されたかを検出します。現在のヘッドセット状態を取得します。

AndroidiOS
30日間ダウンロード
1030
いいね数
5
Pub ポイント
150

パッケージをインストール

flutter pub add flutter_headset_detector

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

AndroidおよびiOSデバイスでヘッドセット接続イベントを検出するFlutterプラグインです。アプリがヘッドセットの挿入または抜き差しに応答できるようにし、現在のヘッドセット状態を提供します。リアルタイムでオーディオ出力の変更を把握する必要がある音声アプリに最適です。このプラグインはFlutterのイベントシステムとシームレスに統合され、最小限の設定で両方のプラットフォームをサポートしています。開発者は、ヘッドセットの有無に基づいてオーディオルーティングやUIの動作を調整することで、ユーザー体験を向上させることができます。

用途

  • オーディオアプリの強化
  • リアルタイムオーディオルーティング
  • ユーザーインターフェースの適応
  • デバイス状態のモニタリング
  • メディア再生コントロール

主な機能

  • ヘッドフォンの挿入/抜き取りイベントを検出します
  • 現在のヘッドホン状態を提供します
  • クロスプラットフォーム(Android & iOS)
  • シンプルなイベントベースの API
  • 軽量かつ信頼性が高い

適している対象

  • オーディオ中心のアプリ
  • メディアプレーヤー
  • アクセシビリティツール
  • ハードウェアフィードバックを必要とするモバイルアプリ
  • 応答性のあるオーディオインターフェースを開発する開発者

注意事項

  • プラットフォーム固有の権限が必要です
  • ヘッドセットの検出のみに制限
  • Bluetoothヘッドセットのサポートなし
  • ネイティブデバイス機能に依存しています
  • 実機でのテストが必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Flutter Headset Detector Plugin

A Flutter plugin to get a headset event.

This is a clone of headset_connection_event, but seperated wired and wireless event.

Current Status

Platform Physical Headset Bluetooth
iOS ✅ ✅
Android ✅ ✅

Usage

To use this plugin, add flutter_headset_detector as a dependency in your pubspec.yaml file.

Example
// Import package
import 'package:flutter_headset_detector/flutter_headset_detector.dart';

// Instantiate it
final headsetDetector = HeadsetDetector();
Map<HeadsetType, HeadsetState> headsetState = {
  HeadsetType.WIRED: HeadsetState.DISCONNECTED,
  HeadsetType.WIRELESS: HeadsetState.DISCONNECTED,
};

// if headset is plugged
headsetDetector.getCurrentState.then((_val){
  headsetState = _val;
  setState(() {
  });
});

// Detect the moment headset is plugged or unplugged with a Listener
headsetDetector.setListener((_val) {
  switch (_val) {
    case HeadsetChangedEvent.WIRED_CONNECTED:
      headsetState[HeadsetType.WIRED] = HeadsetState.CONNECTED;
      break;
    case HeadsetChangedEvent.WIRED_DISCONNECTED:
      headsetState[HeadsetType.WIRED] = HeadsetState.DISCONNECTED;
      break;
    case HeadsetChangedEvent.WIRELESS_CONNECTED:
      headsetState[HeadsetType.WIRELESS] = HeadsetState.CONNECTED;
      break;
    case HeadsetChangedEvent.WIRELESS_DISCONNECTED:
      headsetState[HeadsetType.WIRELESS] = HeadsetState.DISCONNECTED;
      break;
  }
  setState(() {
  });
});

// Remove the Listener
headsetDetector.removeListener();

Screenshot

  • There are no connected headphones:

  • There are wired connected headphones:

  • There are Bluetooth connected headphones:

  • All types are connected:

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。