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,
|
||||
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<FullscreenBody> 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) {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -47,6 +47,7 @@ dependencies:
|
|||
transparent_image:
|
||||
tuple:
|
||||
video_player:
|
||||
path: ../plugins/packages/video_player/video_player
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
Loading…
Reference in a new issue