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;
|
return player.dispose;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
final aspectRatio = switch (info) {
|
final controls = useCallback(
|
||||||
VideoInfo(:final width?, :final height?) when width > 0 && height > 0 =>
|
(VideoState _) =>
|
||||||
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: (_) =>
|
|
||||||
// Until media_kit moves to material_ui, this Material is needed.
|
// Until media_kit moves to material_ui, this Material is needed.
|
||||||
Material(
|
Material(
|
||||||
type: .transparency,
|
type: .transparency,
|
||||||
child: Stack(
|
child: ValueListenableBuilder(
|
||||||
|
valueListenable: loaded,
|
||||||
|
builder: (_, loaded, _) => Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
behavior: .opaque,
|
behavior: .opaque,
|
||||||
onTap: loaded.value ? player.playOrPause : null,
|
onTap: loaded ? player.playOrPause : null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
|
|
@ -98,7 +87,7 @@ class const VideoPlayer(
|
||||||
padding: const .only(left: 4, right: 4, top: 16),
|
padding: const .only(left: 4, right: 4, top: 16),
|
||||||
child: PlayerControls(
|
child: PlayerControls(
|
||||||
player,
|
player,
|
||||||
loading: !loaded.value,
|
loading: !loaded,
|
||||||
size: info?.size,
|
size: info?.size,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
actions: .new([
|
actions: .new([
|
||||||
|
|
@ -107,8 +96,7 @@ class const VideoPlayer(
|
||||||
final fullscreen = isFullscreen(context);
|
final fullscreen = isFullscreen(context);
|
||||||
|
|
||||||
return IconButton(
|
return IconButton(
|
||||||
onPressed: () =>
|
onPressed: () => toggleFullscreen(context),
|
||||||
toggleFullscreen(context),
|
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
tooltip: fullscreen
|
tooltip: fullscreen
|
||||||
? "Exit 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