flutter_ringtone_player

A simple ringtone, alarm & notification player plugin.

pub package

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

You can also specify some additional parameters (works only on Android with API 28 and above):

FlutterRingtonePlayer.playNotification(volume: 0.5, looping: true);

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,
  volume: 0.1,
);

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

MethodAndroidiOS
playAlarmSystem#DEFAULT_ALARM_ALERT_URIIosSounds.alarm
playNotificationSystem#DEFAULT_NOTIFICATION_URIIosSounds.triTone
playRingtoneSystem#DEFAULT_RINGTONE_URIIosSounds.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,
);

Libraries

android_sounds
flutter_ringtone_player
ios_sounds