Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE-4745: add pre-initialization spinner and buffer loading secondary value to … #1416

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions lib/pages/drive_detail/components/fs_entry_preview_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ class _VideoPlayerWidgetState extends State<VideoPlayerWidget>
videoValue.duration > Duration.zero &&
_errorMessage == null;

var bufferedValue = videoValue.buffered.isNotEmpty
? videoValue.buffered.last.end.inMilliseconds.toDouble()
: 0.0;

return VisibilityDetector(
key: const Key('video-player'),
onVisibilityChanged: (VisibilityInfo info) async {
Expand Down Expand Up @@ -228,10 +232,19 @@ class _VideoPlayerWidgetState extends State<VideoPlayerWidget>
.smallBold700(color: colors.themeFgMuted)
.copyWith(fontSize: 13),
))
: AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: VideoPlayer(_videoPlayerController,
key: const Key('videoPlayer')))),
: !videoValue.isInitialized
? const Center(
child: SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(),
),
)
: AspectRatio(
aspectRatio:
_videoPlayerController.value.aspectRatio,
child: VideoPlayer(_videoPlayerController,
key: const Key('videoPlayer')))),
],
))),
Padding(
Expand All @@ -258,6 +271,7 @@ class _VideoPlayerWidgetState extends State<VideoPlayerWidget>
value: min(
videoValue.position.inMilliseconds.toDouble(),
videoValue.duration.inMilliseconds.toDouble()),
secondaryTrackValue: bufferedValue,
min: 0.0,
max: videoValue.duration.inMilliseconds.toDouble(),
onChangeStart: !controlsEnabled
Expand Down Expand Up @@ -595,6 +609,10 @@ class _FullScreenVideoPlayerWidgetState
var currentTime = getTimeString(videoValue.position);
var duration = getTimeString(videoValue.duration);

var bufferedValue = videoValue.buffered.isNotEmpty
? videoValue.buffered.last.end.inMilliseconds.toDouble()
: 0.0;

return Scaffold(
body: Center(
child: Stack(
Expand All @@ -614,7 +632,15 @@ class _FullScreenVideoPlayerWidgetState
.smallBold700(color: colors.themeFgMuted)
.copyWith(fontSize: 13),
))
: _videoPlayer ?? const SizedBox.shrink(),
: !videoValue.isInitialized
? const Center(
child: SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(),
),
)
: _videoPlayer ?? const SizedBox.shrink(),
)),
MouseRegion(
onHover: (event) {
Expand Down Expand Up @@ -726,6 +752,7 @@ class _FullScreenVideoPlayerWidgetState
videoValue
.duration.inMilliseconds
.toDouble()),
secondaryTrackValue: bufferedValue,
min: 0.0,
max: videoValue
.duration.inMilliseconds
Expand Down