added vocabulary audio reading
This commit is contained in:
@@ -57,7 +57,8 @@ class _VocabScreenState extends State<VocabScreen> {
|
||||
}
|
||||
|
||||
var items = await repo.loadVocabulary();
|
||||
if (items.isEmpty) {
|
||||
if (items.isEmpty ||
|
||||
items.every((item) => item.pronunciationAudios.isEmpty)) {
|
||||
setState(() {
|
||||
_status = 'Fetching deck...';
|
||||
});
|
||||
@@ -149,7 +150,6 @@ class _VocabScreenState extends State<VocabScreen> {
|
||||
_asked += 1;
|
||||
if (isCorrect) {
|
||||
_score += 1;
|
||||
_audioPlayer.play(AssetSource('sfx/confirm.mp3'));
|
||||
srsItem.srsStage += 1;
|
||||
} else {
|
||||
srsItem.srsStage = max(0, srsItem.srsStage - 1);
|
||||
@@ -183,7 +183,23 @@ class _VocabScreenState extends State<VocabScreen> {
|
||||
ScaffoldMessenger.of(context).showSnackBar(snack);
|
||||
}
|
||||
|
||||
Future.delayed(const Duration(milliseconds: 900), _nextQuestion);
|
||||
if (isCorrect) {
|
||||
await _audioPlayer.play(AssetSource('sfx/confirm.mp3'));
|
||||
final maleAudios =
|
||||
current.pronunciationAudios.where((a) => a.gender == 'male');
|
||||
if (maleAudios.isNotEmpty) {
|
||||
try {
|
||||
await _audioPlayer.play(UrlSource(maleAudios.first.url));
|
||||
} catch (e) {
|
||||
// Ignore player errors
|
||||
}
|
||||
}
|
||||
await Future.delayed(const Duration(milliseconds: 400));
|
||||
} else {
|
||||
await Future.delayed(const Duration(milliseconds: 900));
|
||||
}
|
||||
|
||||
_nextQuestion();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user