From fb63b8ca331123ded71399d5cddb886d5d8e4135 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Tue, 17 Mar 2020 20:14:00 +0900 Subject: [PATCH] fullscreen: decode video from URI instead of path --- lib/widgets/fullscreen/fullscreen_body.dart | 12 +++++------- lib/widgets/fullscreen/image_view.dart | 2 +- pubspec.lock | 8 ++++---- pubspec.yaml | 1 + 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/widgets/fullscreen/fullscreen_body.dart b/lib/widgets/fullscreen/fullscreen_body.dart index b266aa856..b312435e9 100644 --- a/lib/widgets/fullscreen/fullscreen_body.dart +++ b/lib/widgets/fullscreen/fullscreen_body.dart @@ -156,7 +156,7 @@ class FullscreenBodyState extends State with SingleTickerProvide valueListenable: _currentVerticalPage, builder: (context, page, child) { 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 ? Positioned( bottom: 0, @@ -243,15 +243,13 @@ class FullscreenBodyState extends State with SingleTickerProvide final entry = _currentHorizontalPage != null && _currentHorizontalPage < entries.length ? entries[_currentHorizontalPage] : null; if (entry == null || !entry.isVideo) return; - final path = entry.path; - if (path == null) return; - - var controllerEntry = _videoControllers.firstWhere((kv) => kv.item1 == entry.path, orElse: () => null); + final uri = entry.uri; + var controllerEntry = _videoControllers.firstWhere((kv) => kv.item1 == uri, orElse: () => null); if (controllerEntry != null) { _videoControllers.remove(controllerEntry); } else { - final controller = VideoPlayerController.file(File(path))..initialize(); - controllerEntry = Tuple2(path, controller); + final controller = VideoPlayerController.uri(uri)..initialize(); + controllerEntry = Tuple2(uri, controller); } _videoControllers.insert(0, controllerEntry); while (_videoControllers.length > 3) { diff --git a/lib/widgets/fullscreen/image_view.dart b/lib/widgets/fullscreen/image_view.dart index 61cacb82a..ccc16a690 100644 --- a/lib/widgets/fullscreen/image_view.dart +++ b/lib/widgets/fullscreen/image_view.dart @@ -26,7 +26,7 @@ class ImageView extends StatelessWidget { const backgroundDecoration = BoxDecoration(color: Colors.transparent); 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( child: videoController != null ? AvesVideo( diff --git a/pubspec.lock b/pubspec.lock index 6221cc289..1f950768f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -455,10 +455,10 @@ packages: video_player: dependency: "direct main" description: - name: video_player - url: "https://pub.dartlang.org" - source: hosted - version: "0.10.8+1" + path: "../plugins/packages/video_player/video_player" + relative: true + source: path + version: "0.10.8+2" video_player_platform_interface: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 18e5669dd..a2062356f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,6 +47,7 @@ dependencies: transparent_image: tuple: video_player: + path: ../plugins/packages/video_player/video_player dev_dependencies: flutter_test: