fullscreen: decode video from URI instead of path
This commit is contained in:
parent
9357a49f4a
commit
fb63b8ca33
4 changed files with 11 additions and 12 deletions
|
@ -156,7 +156,7 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
||||||
valueListenable: _currentVerticalPage,
|
valueListenable: _currentVerticalPage,
|
||||||
builder: (context, page, child) {
|
builder: (context, page, child) {
|
||||||
final showOverlay = entry != null && page == imagePage;
|
final showOverlay = entry != null && page == imagePage;
|
||||||
final videoController = showOverlay && entry.isVideo ? _videoControllers.firstWhere((kv) => kv.item1 == entry.path, orElse: () => null)?.item2 : null;
|
final videoController = showOverlay && entry.isVideo ? _videoControllers.firstWhere((kv) => kv.item1 == entry.uri, orElse: () => null)?.item2 : null;
|
||||||
return showOverlay
|
return showOverlay
|
||||||
? Positioned(
|
? Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
@ -243,15 +243,13 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
||||||
final entry = _currentHorizontalPage != null && _currentHorizontalPage < entries.length ? entries[_currentHorizontalPage] : null;
|
final entry = _currentHorizontalPage != null && _currentHorizontalPage < entries.length ? entries[_currentHorizontalPage] : null;
|
||||||
if (entry == null || !entry.isVideo) return;
|
if (entry == null || !entry.isVideo) return;
|
||||||
|
|
||||||
final path = entry.path;
|
final uri = entry.uri;
|
||||||
if (path == null) return;
|
var controllerEntry = _videoControllers.firstWhere((kv) => kv.item1 == uri, orElse: () => null);
|
||||||
|
|
||||||
var controllerEntry = _videoControllers.firstWhere((kv) => kv.item1 == entry.path, orElse: () => null);
|
|
||||||
if (controllerEntry != null) {
|
if (controllerEntry != null) {
|
||||||
_videoControllers.remove(controllerEntry);
|
_videoControllers.remove(controllerEntry);
|
||||||
} else {
|
} else {
|
||||||
final controller = VideoPlayerController.file(File(path))..initialize();
|
final controller = VideoPlayerController.uri(uri)..initialize();
|
||||||
controllerEntry = Tuple2(path, controller);
|
controllerEntry = Tuple2(uri, controller);
|
||||||
}
|
}
|
||||||
_videoControllers.insert(0, controllerEntry);
|
_videoControllers.insert(0, controllerEntry);
|
||||||
while (_videoControllers.length > 3) {
|
while (_videoControllers.length > 3) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ImageView extends StatelessWidget {
|
||||||
const backgroundDecoration = BoxDecoration(color: Colors.transparent);
|
const backgroundDecoration = BoxDecoration(color: Colors.transparent);
|
||||||
|
|
||||||
if (entry.isVideo) {
|
if (entry.isVideo) {
|
||||||
final videoController = videoControllers.firstWhere((kv) => kv.item1 == entry.path, orElse: () => null)?.item2;
|
final videoController = videoControllers.firstWhere((kv) => kv.item1 == entry.uri, orElse: () => null)?.item2;
|
||||||
return PhotoView.customChild(
|
return PhotoView.customChild(
|
||||||
child: videoController != null
|
child: videoController != null
|
||||||
? AvesVideo(
|
? AvesVideo(
|
||||||
|
|
|
@ -455,10 +455,10 @@ packages:
|
||||||
video_player:
|
video_player:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: video_player
|
path: "../plugins/packages/video_player/video_player"
|
||||||
url: "https://pub.dartlang.org"
|
relative: true
|
||||||
source: hosted
|
source: path
|
||||||
version: "0.10.8+1"
|
version: "0.10.8+2"
|
||||||
video_player_platform_interface:
|
video_player_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -47,6 +47,7 @@ dependencies:
|
||||||
transparent_image:
|
transparent_image:
|
||||||
tuple:
|
tuple:
|
||||||
video_player:
|
video_player:
|
||||||
|
path: ../plugins/packages/video_player/video_player
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in a new issue