From 99cfeb01569f45d2af4ae90755b9f559188cb6bf Mon Sep 17 00:00:00 2001 From: Alex Baron Date: Wed, 17 May 2023 11:27:09 +0800 Subject: [PATCH] Fix to cap very large position values --- lib/src/video_player/method_channel_video_player.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/video_player/method_channel_video_player.dart b/lib/src/video_player/method_channel_video_player.dart index a4066d5f0..cb5f7542b 100644 --- a/lib/src/video_player/method_channel_video_player.dart +++ b/lib/src/video_player/method_channel_video_player.dart @@ -217,11 +217,16 @@ class MethodChannelVideoPlayer extends VideoPlayerPlatform { ) ?? 0; + // Sometimes the media server returns a absolute position far greater than + // the datetime instance can handle. This caps the value to the maximum the datetime + // can use. + if (milliseconds > 8640000000000000 || milliseconds < -8640000000000000) return null; + if (milliseconds <= 0) return null; return DateTime.fromMillisecondsSinceEpoch(milliseconds); } - + @override Future enablePictureInPicture(int? textureId, double? top, double? left, double? width, double? height) async {