Closed jeremiahseun closed 5 months ago
Hi @jeremiahseun
Be careful when you use path like /Users/mac/Library/Developer/CoreSimulator/Devices/D0360210-87B3-4A0A-93FB-AC4D72065BB0/data/Containers/Data/Application/8774F5C9-A903-431D-B063-FB3B63780EF5/Documents/Great God.m4a
because the part "8774F5C9-A903-431D-B063-FB3B63780EF5" is an id that will change every time you update your app. I recommend to use the relative file path instead, which should be just: Great God.m4a
.
About using project assets, you must rename your asset
folder to assets
. Otherwise your audios won't be imported.
Let me know if it helps.
@gdelataillade I realized that it works fine on Android.
The assets
part is working now on iOS, thanks.
I'm using path_provider
's getApplicationDocumentsDirectory()
for both platforms.
I used this because this is one of the most consistent ones that works for both platforms. I also don't want it deleted by the user.
What do you think I can do?
Hi @jeremiahseun
You can save your audios like this:
import 'package:path_provider/path_provider.dart';
import 'dart:io';
Future<void> saveFile(String fileName, List<int> bytes) async {
final directory = await getApplicationDocumentsDirectory();
final path = '${directory.path}/$fileName';
final file = File(path);
await file.writeAsBytes(bytes);
}
In your case, you could do:
await saveFile('Great God.m4a', fileBytes);
Then, you can pass it like this: assetAudioPath: 'Great God.m4a'
.
This way, the audio file will be correctly located in the app’s Documents directory on both iOS and Android.
Let me know how it goes!
It worked! Thanks.
I was thinking using the filePath is the solution.
Alarm plugin version ^3.1.4
Describe the bug I have been unable to add alarm because of this error. I have tried audio files from assets folder, and also downloaded asset. It didn't work. Here is the error message I am getting.
To Reproduce Steps to reproduce the behavior:
Expected behavior I ought to get a success message that it has been scheduled successfully.
Screenshots If applicable, add screenshots to help explain your problem.
Device info Ex: iPhone SE (2nd generation) iOS Simulator
Additional context Add any other context about the problem here.