Rank 1: Thread
hello guys can someone help me out. i keep getting this error trying to update a database in flutter: 'converting object to an encodable object failed: instance of DateTime'. i am using the appwrite cloud.
Votes
0
Replies
12
Participants
Unknown
Messages
13
Rank 1: Thread
hello guys can someone help me out. i keep getting this error trying to update a database in flutter: 'converting object to an encodable object failed: instance of DateTime'. i am using the appwrite cloud.
Admin
It would help if you shared more detail like your code, the exact error, and your data
Rank 1: Thread
Thanks, i have been able to find a work around by turning my DateTime variables into milliseconds and saving them as integer attribute on appwrite .
Admin
Your problem was probably a dart problem since you can't jsonEncode() some types like DateTime. If you have a date time attribute in appwrite, you would convert it by calling d.toUtc().toIso8601String() or something like that
Rank 1: Thread
tried that, didn't work.
Admin
So what's the problem now?
Rank 1: Thread
the problem now: i am using the http package in flutter to get video files from appwrite cloud storage, but the wait time is too long compared to when i use firebase. is there something i need to do?. here is what my function looks like
Rank 1: Thread
` Future _initializeVideo() async {
debugPrint('----->STARTING VIDEO INITIALIZER');
final String videoFileName = getAppwriteFileName(widget.videoUrl);
final String cachePath = await getCachePath();
final File videoFile = File('$cachePath/$videoFileName');
try {
if (videoFile.existsSync()) {
debugPrint('----->VIDEO ALREADY EXISTS');
_controller = VideoPlayerController.file(videoFile);
} else {
debugPrint('----->DOWNLOADING VIDEO');
var headers = {
"Content-Type": "video/mp4",
"X-Appwrite-Project": "my project id",
"X-Appwrite-Key":
"my api key"
};
final http.Response response =
await http.get(Uri.parse(widget.videoUrl), headers: headers);
await videoFile.create(recursive: true);
await videoFile.writeAsBytes(response.bodyBytes);
debugPrint('----->SETTING CONTROLLER TO FILE');
debugPrint('-----> ${videoFile.absolute}');
_controller = VideoPlayerController.file(videoFile);
}
_initializeVideoFuture = _controller.initialize().then((value) {
debugPrint('----->INITIALIZING VIDEO');
setState(() {
_controller.setLooping(true);
isLandscape = isLandscapeVideo();
isready = true;
});
});
} catch (error) {
debugPrint('----->Error initializing video: $error');
// Handle the error, e.g., display an error message to the user
}
}`
Admin
This isn't in your flutter app is it?
Admin
Why are you using http package for this?
Rank 1: Thread
i was trying to make it a progressive download and playback that's why i was using the http package. but i failed and i am now using the appwrite sdk function storage.getFileDownload but its still as slow as using the http package 👀
Rank 1: Thread
do you know how i can implement progressive video download and playback in flutter?
Admin
You can try to put the URL into your player.
There are a couple of factors at play here.