
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
- Redirect URL sends HTTP instead of HTTPS...
I am not sure since when this issue is present, but my Google and Apple redirect URI are no longer pointing to the HTTPS redirect URI when I try to use OAuth. ...
- Failing to run document operations on sd...
Could someone point me in the right direction I'm going in cirlces. I have a problem with sdks and my self-hosted server in production (for ~3 years) I have bee...
- Functions fail to deploy after switching...
Hi <@1087889306208718959> , after switching my self-hosted Appwrite instance to use AWS S3 as the storage backend, my Cloud Functions stopped working. I’m runni...
