playTone method
Plays the DTMF Tones Associated with the digits
. Each tone is played for the duration durationMs
in milliseconds
Returns true if tone played successfully
Implementation
bool playTone(String digits, int? durationMs) {
dynamic audioContext = js.context.callMethod('AudioContext',
['new (window.AudioContext || window.webkitAudioContext)()']);
for (var i in digits.split('')) {
var tone = Tone(
context: audioContext,
frequency1: allFrequencies[i]![0],
frequency2: allFrequencies[i]![1]);
if (tone.status == 0) {
tone.start();
tone.stop();
return true;
}
}
return false;
}