
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.

It would help if you shared more detail like your code, the exact error, and your data

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 .

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

tried that, didn't work.

So what's the problem now?

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

` Future<void> _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
}
}`

This isn't in your flutter app is it?

Why are you using http package for this?

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 👀

do you know how i can implement progressive video download and playback in flutter?

You can try to put the URL into your player.
There are a couple of factors at play here.
- There could be network latency due to where the cloud server is in relation to where you are.
- If you try to download the entire file and then load that into your player, the user has to wait for the full download. If you put the URL into the player, the player will request chunks of the file and then start playing when some chunks are available while still downloading the rest.
Recommended threads
- OAuth2 with IPhone When users enables "H...
I am using Appwrite OAuth2 to authenticate users in my app (Flutter) Normally, I am using the user's email for the authentication, when he first registers , and...
- Still showing this after complete my pay...
This project is in readonly mode. Please contact the organization admin for details.
- flutter_web_auth_2 needs to be updated!
The appwrite SDK is using an old version of flutter_web_auth_2 which I beleive is now deprecated, or atleast, isn't working for me. iOS, Linux, Web, Windows stu...
