forked from Nexus/nexus
parent
7b542d8d1e
commit
2d8cd4eff2
1 changed files with 84 additions and 80 deletions
|
|
@ -38,30 +38,19 @@ class const VideoPlayer(
|
|||
return player.dispose;
|
||||
}, []);
|
||||
|
||||
final aspectRatio = switch (info) {
|
||||
VideoInfo(:final width?, :final height?) when width > 0 && height > 0 =>
|
||||
width / height,
|
||||
_ => 16 / 9,
|
||||
};
|
||||
|
||||
return ConstrainedBox(
|
||||
constraints: const .new(maxHeight: 300),
|
||||
child: AspectRatio(
|
||||
aspectRatio: aspectRatio,
|
||||
child: ClipRRect(
|
||||
borderRadius: .circular(12),
|
||||
child: Video(
|
||||
controller: controller,
|
||||
controls: (_) =>
|
||||
final controls = useCallback(
|
||||
(VideoState _) =>
|
||||
// Until media_kit moves to material_ui, this Material is needed.
|
||||
Material(
|
||||
type: .transparency,
|
||||
child: Stack(
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: loaded,
|
||||
builder: (_, loaded, _) => Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
behavior: .opaque,
|
||||
onTap: loaded.value ? player.playOrPause : null,
|
||||
onTap: loaded ? player.playOrPause : null,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
|
|
@ -98,7 +87,7 @@ class const VideoPlayer(
|
|||
padding: const .only(left: 4, right: 4, top: 16),
|
||||
child: PlayerControls(
|
||||
player,
|
||||
loading: !loaded.value,
|
||||
loading: !loaded,
|
||||
size: info?.size,
|
||||
color: Colors.white,
|
||||
actions: .new([
|
||||
|
|
@ -107,8 +96,7 @@ class const VideoPlayer(
|
|||
final fullscreen = isFullscreen(context);
|
||||
|
||||
return IconButton(
|
||||
onPressed: () =>
|
||||
toggleFullscreen(context),
|
||||
onPressed: () => toggleFullscreen(context),
|
||||
color: Colors.white,
|
||||
tooltip: fullscreen
|
||||
? "Exit fullscreen"
|
||||
|
|
@ -130,6 +118,22 @@ class const VideoPlayer(
|
|||
),
|
||||
),
|
||||
),
|
||||
[uri, encrypted, filename, info],
|
||||
);
|
||||
|
||||
final aspectRatio = switch (info) {
|
||||
VideoInfo(:final width?, :final height?) when width > 0 && height > 0 =>
|
||||
width / height,
|
||||
_ => 16 / 9,
|
||||
};
|
||||
|
||||
return ConstrainedBox(
|
||||
constraints: const .new(maxHeight: 300),
|
||||
child: AspectRatio(
|
||||
aspectRatio: aspectRatio,
|
||||
child: ClipRRect(
|
||||
borderRadius: .circular(12),
|
||||
child: Video(controller: controller, controls: controls),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue