You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:just_audio/just_audio.dart';
|
|
import 'package:queuing_system/utils/call_type.dart';
|
|
|
|
class CallByVoice{
|
|
|
|
final String lang;
|
|
final String preVoice;
|
|
final String ticketNo;
|
|
final String postVoice;
|
|
|
|
CallByVoice(this.ticketNo, {this.lang = 'en', @required this.preVoice, @required this.postVoice});
|
|
|
|
final _player = AudioPlayer();
|
|
start() async{
|
|
|
|
// Create Pre Voice Players
|
|
if(preVoice != null && preVoice.isNotEmpty) {
|
|
await _player.setAsset('assets/voice_$lang/$preVoice');
|
|
await _player.play();
|
|
}
|
|
|
|
// Create Ticket Number Voice Players
|
|
final characters = ticketNo.characters.toList();
|
|
for(int i = 0; i< characters.length; i++){
|
|
final no = characters[i];
|
|
if(no.isNotEmpty){
|
|
await Future.delayed(const Duration(milliseconds: 200));
|
|
|
|
await _player.stop();
|
|
await _player.setAsset('assets/voice_$lang/$no.mp3');
|
|
await _player.play();
|
|
}
|
|
}
|
|
|
|
|
|
// Create Post Voice Players
|
|
if(postVoice != null && postVoice.isNotEmpty) {
|
|
await Future.delayed(const Duration(milliseconds: 1000));
|
|
|
|
await _player.stop();
|
|
await _player.setAsset('assets/voice_$lang/$postVoice');
|
|
await _player.play();
|
|
}
|
|
|
|
_player.dispose();
|
|
}
|
|
} |