1.2.1
At the moment, startPlayer requires a URI, which the assets don't have. I think I can hack a workaround to this via path_provider, but it would be useful to be able to playback directly from assets as well.
Thanks for the library!
For anyone else needing a temp fix to this, https://github.com/palfrey/spaceteam-timer/blob/8d1c2e0a4cd4bb991b42a0ca02859263d24d1984/lib/setup.dart has setupMusicFiles which makes sure all my assets are dumped to the filesystem, and pathForLength that will get the path to the file. flutterSound.startPlayer('file://$path') then works fine.
Thanks @palfrey
Here's what I used, based on your suggestion:
Future<String> setupMusicFile() async {
final dir = await getApplicationDocumentsDirectory();
final file = File('${dir.path}/pad.mp3');
if (!await file.exists()) {
var data = await rootBundle.load('resources/sounds/pad.mp3');
await file.writeAsBytes(data.buffer.asInt8List());
}
return file.path;
}
and then something like this...
setupMusicFile().then((path) {
if (!flutterSound.isPlaying) {
flutterSound.startPlayer(path);
}
});
This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.
Most helpful comment
For anyone else needing a temp fix to this, https://github.com/palfrey/spaceteam-timer/blob/8d1c2e0a4cd4bb991b42a0ca02859263d24d1984/lib/setup.dart has
setupMusicFileswhich makes sure all my assets are dumped to the filesystem, andpathForLengththat will get the path to the file.flutterSound.startPlayer('file://$path')then works fine.