Closed explorer-source closed 11 months ago
As mentioned in README, you can detect is there something wrong when calling controller.initialize()
controller.initialize().then((value) {
if (controller.value.isInitialized) {
controller.play();
setState(() {});
} else {
log("video file load failed");
}
});
You can also detect error during playing by controller.value.errorDescription != null
if (fileExists) {
videoController = WinVideoPlayerController.file(file);
} else {
videoController = WinVideoPlayerController.network(wholeUrl);
}
videoController.initialize().then((value) {
if (videoController.value.isInitialized) {
videoController.play();
videoController.setLooping(true);
videoLoaded = true;
setState(() {});
} else {
print('video load failed');
}
});
isInitialized is not sufficient because I'm showing CircularProgressIndicator
till videoLoaded
becomes true
yet it crashes
return videoLoaded
? Center(
child: Texture(
textureId: videoController.textureId_,
filterQuality: FilterQuality.medium,
),
)
: const Center(child: CircularProgressIndicator());
Could you upload the video file that can reproduce this issue ?
Ohh I found the problem, missing extension is the reason. I removed the extension from the file when saving to file so it doesn't show up as video in File explorer immediately for "security" reasons. You can change file from GxDhHlCNuO.mp4
to GxDhHlCNuO
it crashes.
While playing the network video, my app caches the video in
temp dir
so that the next time the user enters, it plays from the cache. When the user interrupts the download of the mp4 while it is not fully completed, it appears to crash without any error message. Is it possible to check for errors before playing so that I can play from the network instead or maybe just show error image?