Skip to content

Commit

Permalink
Fix bug where sound can be set to value with no mp4 file
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mabe committed Dec 22, 2024
1 parent ff69f6a commit 852291a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/pages/set_sounds/constants/sounds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const List<String> soundsList = <String>[
'ding',
'ding-sequence',
'thunk',
'none',
'',
];

const List<String> countdownSounds = <String>[
'countdown-beep',
'short-rest-beep',
'none',
'',
];

var soundNames = {
Expand All @@ -38,5 +38,5 @@ var soundNames = {
"short-rest-beep": "Beep",
"short-whistle": "Short whistle",
"thunk": "Thunk",
"none": "None"
"": "None"
};
12 changes: 6 additions & 6 deletions lib/pages/set_sounds/set_sounds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: soundsList,
onFinished: (value) async {
if (value != 'none') {
if (value != '') {
await pool.play(await soundIdMap[value]);
}
widget.timer.soundSettings.workSound = value!;
Expand All @@ -129,7 +129,7 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: soundsList,
onFinished: (value) async {
if (value != 'none') {
if (value != '') {
await pool.play(await soundIdMap[value]);
}
widget.timer.soundSettings.restSound = value!;
Expand All @@ -142,7 +142,7 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: soundsList,
onFinished: (value) async {
if (value != 'none') {
if (value != '') {
await pool.play(await soundIdMap[value]);
}
widget.timer.soundSettings.halfwaySound =
Expand All @@ -156,7 +156,7 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: countdownSounds,
onFinished: (value) async {
if (value != 'none') {
if (value != '') {
await pool.play(await soundIdMap[value]);
}
widget.timer.soundSettings.countdownSound =
Expand All @@ -170,7 +170,7 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: soundsList,
onFinished: (value) async {
if (value != 'none') {
if (value != '') {
await pool.play(await soundIdMap[value]);
}
widget.timer.soundSettings.endSound = value!;
Expand All @@ -190,7 +190,7 @@ class _SetSoundsState extends State<SetSounds> {
}

static Future<int> loadSound(String sound, Soundpool pool) async {
if (sound != "none") {
if (sound != "") {
return await rootBundle
.load("packages/background_hiit_timer/lib/assets/audio/$sound.mp3")
.then((ByteData soundData) {
Expand Down

0 comments on commit 852291a

Please sign in to comment.