-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathdtmf.dart
More file actions
33 lines (31 loc) · 1.44 KB
/
dtmf.dart
File metadata and controls
33 lines (31 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import 'dart:async';
import 'package:flutter/services.dart';
/// Dtmf enables playing DTMF tones crossplatform
class Dtmf {
static const MethodChannel _channel = const MethodChannel('flutter_dtmf');
/// Plays the DTMF Tones Associated with the [digits]. Each tone is played for the duration [durationMs] in milliseconds
/// at the specified volume. If no volume is specified, the system default is used. Volume value should be between
/// 0 and 1.
/// Returns true if tone played successfully
/// Set ignoreDtmfSystemSettings to true, if you want to play sound even when dtmf sounds are disable on the device (ex : on a tablet)
/// Set forceMaxVolume to true if you want to increase max volume to the max volume of the phone, (and not just max volume of DTMF sounds).
/// If you force max Volume to true, you can still control the volume with the volume atribute.
///
static Future<bool?> playTone(
{required String digits,
int durationMs = 160,
double samplingRate = 4000,
double volume = 1,
bool ignoreDtmfSystemSettings = false,
bool forceMaxVolume = false}) async {
final Map<String, Object?> args = <String, dynamic>{
"digits": digits,
"samplingRate": samplingRate,
"durationMs": durationMs,
"volume": volume,
"ignoreDtmfSystemSettings": ignoreDtmfSystemSettings,
"forceMaxVolume": forceMaxVolume
};
return await _channel.invokeMethod('playTone', args);
}
}