π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Automatically change to media kit if video not playable on ios + let the user manually switch to media kit
ashilkn4422b4a7b038
diff --git a/mobile/lib/ui/viewer/file/video_widget.dart b/mobile/lib/ui/viewer/file/video_widget.dartindex 7751cf0147..c582cc1e7a 100644--- a/mobile/lib/ui/viewer/file/video_widget.dart+++ b/mobile/lib/ui/viewer/file/video_widget.dart@@ -1,6 +1,7 @@import "dart:async";import "package:flutter/material.dart";+import "package:logging/logging.dart";import "package:photos/core/event_bus.dart";import "package:photos/events/use_media_kit_for_video.dart";import "package:photos/models/file/file.dart";@@ -23,6 +24,7 @@ class VideoWidget extends StatefulWidget {}class _VideoWidgetState extends State<VideoWidget> {+ final _logger = Logger("VideoWidget");bool useNativeVideoPlayer = true;late final StreamSubscription<UseMediaKitForVideo>useMediaKitForVideoSubscription;@@ -32,6 +34,7 @@ class _VideoWidgetState extends State<VideoWidget> {super.initState();useMediaKitForVideoSubscription =Bus.instance.on<UseMediaKitForVideo>().listen((event) {+ _logger.info("Switching to MediaKit for video playback");setState(() {useNativeVideoPlayer = false;});diff --git a/mobile/lib/ui/viewer/file/video_widget_native.dart b/mobile/lib/ui/viewer/file/video_widget_native.dartindex c76d9d5e5e..eeec81346d 100644--- a/mobile/lib/ui/viewer/file/video_widget_native.dart+++ b/mobile/lib/ui/viewer/file/video_widget_native.dart@@ -1,13 +1,16 @@import "dart:async";import "dart:io";+import "package:el_tooltip/el_tooltip.dart";import "package:flutter/material.dart";+import "package:flutter/services.dart";import "package:logging/logging.dart";import "package:native_video_player/native_video_player.dart";import "package:photos/core/constants.dart";import "package:photos/core/event_bus.dart";import "package:photos/events/guest_view_event.dart";import "package:photos/events/pause_video_event.dart";+import "package:photos/events/use_media_kit_for_video.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/file/extensions/file_props.dart";import "package:photos/models/file/file.dart";@@ -62,6 +65,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>final _showControls = ValueNotifier(true);final _isSeeking = ValueNotifier(false);final _debouncer = Debouncer(const Duration(milliseconds: 2000));+ final _elTooltipController = ElTooltipController();@overridevoid initState() {@@ -150,6 +154,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>_isSeeking.removeListener(_seekListener);_isSeeking.dispose();_debouncer.cancelDebounceTimer();+ _elTooltipController.dispose();super.dispose();}@@ -202,6 +207,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>behavior: HitTestBehavior.opaque,onTap: () {_showControls.value = !_showControls.value;+ _elTooltipController.hide();if (widget.playbackCallback != null) {widget.playbackCallback!(!_showControls.value);}@@ -210,6 +216,25 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>constraints: const BoxConstraints.expand(),),),+ Platform.isAndroid+ ? Positioned(+ bottom: verticalMargin,+ right: 0,+ child: SafeArea(+ child: GestureDetector(+ onLongPress: () {+ Bus.instance.fire(UseMediaKitForVideo());+ HapticFeedback.vibrate();+ },+ child: Container(+ width: 100,+ height: 180,+ color: Colors.transparent,+ ),+ ),+ ),+ )+ : const SizedBox.shrink(),Positioned.fill(child: Center(child: ValueListenableBuilder(@@ -248,18 +273,108 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>padding: EdgeInsets.only(bottom: widget.isFromMemories ? 32 : 0,),- child: ValueListenableBuilder(- valueListenable: _isPlaybackReady,- builder: (BuildContext context, bool value, _) {- return value- ? _SeekBarAndDuration(- controller: _controller,- duration: duration,- showControls: _showControls,- isSeeking: _isSeeking,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.end,+ children: [+ Platform.isAndroid+ ? ValueListenableBuilder(+ valueListenable: _showControls,+ builder: (context, value, _) {+ return AnimatedOpacity(+ duration: const Duration(+ milliseconds: 200,+ ),+ curve: Curves.easeInQuad,+ opacity: value ? 1 : 0,+ child: ElTooltip(+ padding: const EdgeInsets.all(12),+ distance: 4,+ controller: _elTooltipController,+ content: GestureDetector(+ onLongPress: () {+ Bus.instance.fire(+ UseMediaKitForVideo(),+ );+ HapticFeedback.vibrate();+ _elTooltipController.hide();+ },+ child: const Text(+ "Trouble playing video? Long press here to use different player.",+ ),+ ),+ position:+ ElTooltipPosition.topEnd,+ color: backgroundElevatedDark,+ appearAnimationDuration:+ const Duration(+ milliseconds: 200,+ ),+ disappearAnimationDuration:+ const Duration(+ milliseconds: 200,+ ),+ child: GestureDetector(+ onTap: () {+ if (_elTooltipController+ .value ==+ ElTooltipStatus.hidden) {+ _elTooltipController.show();+ } else {+ _elTooltipController.hide();+ }+ _controller?.pause();+ },+ behavior:+ HitTestBehavior.translucent,+ onLongPress: () {+ Bus.instance.fire(+ UseMediaKitForVideo(),+ );+ HapticFeedback.vibrate();+ },+ child: Padding(+ padding:+ const EdgeInsets.fromLTRB(+ 12,+ 0,+ 0,+ 4,+ ),+ child: Container(+ padding:+ const EdgeInsets.all(+ 12,+ ),+ child: Icon(+ Icons+ .question_mark_rounded,+ size: 16,+ color: Colors.white+ .withOpacity(0.15),+ ),+ ),+ ),+ ),+ ),+ );+ },)- : const SizedBox();- },+ : const SizedBox.shrink(),+ ValueListenableBuilder(+ valueListenable: _isPlaybackReady,+ builder:+ (BuildContext context, bool value, _) {+ return value+ ? _SeekBarAndDuration(+ controller: _controller,+ duration: duration,+ showControls: _showControls,+ isSeeking: _isSeeking,+ )+ : const SizedBox();+ },+ ),+ ],),),),@@ -350,6 +465,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>"Error in native video player controller for file gen id: ${widget.file.generatedID}",);_logger.severe(_controller!.onError.value);+ Bus.instance.fire(UseMediaKitForVideo());}Future<void> _onPlaybackReady() async {diff --git a/mobile/pubspec.lock b/mobile/pubspec.lockindex b45f27e55d..28219c70d9 100644--- a/mobile/pubspec.lock+++ b/mobile/pubspec.lock@@ -441,6 +441,14 @@ packages:url: "https://pub.dev"source: hostedversion: "2.3.9"+ el_tooltip:+ dependency: "direct main"+ description:+ name: el_tooltip+ sha256: "0860b00e9390a31dd98369dc16d3b6fa2668fc52df712bd00e86d8931787fc17"+ url: "https://pub.dev"+ source: hosted+ version: "2.2.1"email_validator:dependency: "direct main"description:diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yamlindex 18c59ce4c8..d8bc5a8386 100644--- a/mobile/pubspec.yaml+++ b/mobile/pubspec.yaml@@ -46,6 +46,7 @@ dependencies:dots_indicator: ^2.0.0dotted_border: ^2.1.0dropdown_button2: ^2.0.0+ el_tooltip: ^2.2.1email_validator: ^2.0.1ente_cast:path: plugins/ente_cast