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

パッケージ詳細v4.0.0+4

flutter_ringtone_player

システムのデフォルトの着信音、アラーム、通知用のシンプルなプレイヤー

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

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

flutter pub add flutter_ringtone_player

パッケージ概要

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

AndroidおよびiOSデバイス上でシステムのデフォルトの着信音、アラーム、通知を再生できる軽量なFlutterパッケージです。外部ファイル処理を必要とせずに、組み込みのサウンドリソースにアクセスして再生するためのシンプルなAPIを提供します。リマインダー、アラート、通知音など、デバイス固有のオーディオキューをトリガーする必要があるアプリに最適です。このパッケージはネイティブプラットフォームのオーディオシステムとシームレスに統合され、最小限の構成で両方のプラットフォームをサポートしています。

用途

  • リマインダー アプリでシステム リングトーンを再生する
  • タスク管理ツールでアラーム音を発生させる
  • メッセージアプリでの通知音の再現
  • ユーティリティアプリでデバイスアラート音をシミュレートする
  • サイレントモードのフォールバックをベルトーン再生で有効にする

主な機能

  • システムのデフォルトの着信音へのアクセス
  • Android および iOS のサポート
  • 最小限のセットアップとインテグレーション
  • クロスプラットフォーム互換性
  • シンプルな再生コントロールAPI

適している対象

  • リマインダーやアラートアプリを開発する開発者
  • ネイティブ通知音が必要なアプリ
  • デバイスの音声フィードバックを必要とするユーティリティツール
  • Android および iOS をターゲットとするモバイルアプリ

注意事項

  • 適切なプラットフォーム権限が必要です
  • システム提供のオーディオリソースに限定
  • カスタムリングトーンファイルのサポートなし
  • Android と iOS の間で動作がわずかに異なる場合があります
  • ネイティブシステムのオーディオ利用可能性に依存する

元の README

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

flutter_ringtone_player

A simple ringtone, alarm & notification player plugin.

pub package flutter

Usage

Add following import to your code:

import 'package:flutter_ringtone_player/flutter_ringtone_player.dart';

Then simply call this to play system default notification sound:

FlutterRingtonePlayer().playNotification();

There's also this generic method allowing you to specify in detail what kind of ringtone should be played:

FlutterRingtonePlayer().play(
  android: AndroidSounds.notification,
  ios: IosSounds.glass,
  looping: true, // Android only - API >= 28
  volume: 0.1, // Android only - API >= 28
  asAlarm: false, // Android only - all APIs
);

Also you can specify a custom ringtone from assets, or provide direct path to file that works for both Android and iOS:

FlutterRingtonePlayer().play(fromAsset: "assets/ringtone.wav");  
FlutterRingtonePlayer().play(fromFile: "assets/ringtone.wav");  

You can specify a platform specific ringtone and it will override the one from assets:

FlutterRingtonePlayer().play(  
 fromAsset: "assets/ringtone.wav", // will be the sound on Android
 ios: IosSounds.glass 			   // will be the sound on iOS
 );  
.play() optional attributes
Attribute Description
bool looping Enables looping of ringtone. Requires FlutterRingtonePlayer().stop(); to stop ringing.
double volume Sets ringtone volume in range 0 to 1.0.
bool asAlarm Allows to ignore device's silent/vibration mode and play given sound anyway.

To stop looped ringtone please use:

FlutterRingtonePlayer().stop();

Above works only on Android, and please note that by default Alarm & Ringtone sounds are looped.

Default sounds

Method Android iOS
playAlarm RingtoneManager.TYPE_ALARM IosSounds.alarm
playNotification RingtoneManager.TYPE_NOTIFICATION IosSounds.triTone
playRingtone RingtoneManager.TYPE_RINGTONE IosSounds.electronic
Note on iOS sounds

If you want to use any other sound on iOS you can always specify a valid Sound ID and manually construct [IosSound]:

FlutterRingtonePlayer().play(
  android: AndroidSounds.notification,
  ios: const IosSound(1023),
  looping: true,
  volume: 0.1,
);

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

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