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
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...