Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix: bump native video player

Prateek Sunalb09e911f18cb
diff --git a/mobile/ios/Podfile.lock b/mobile/ios/Podfile.lock
index fa4e5f3a09..1ef345a144 100644
--- a/mobile/ios/Podfile.lock
+++ b/mobile/ios/Podfile.lock
@@ -484,7 +484,7 @@ SPEC CHECKSUMS:
motionphoto: 584b43031ead3060225cdff08fa49818879801d2
move_to_background: 155f7bfbd34d43ad847cb630d2d2d87c17199710
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
- native_video_player: b65c58951ede2f93d103a25366bdebca95081265
+ native_video_player: e363dd14f6a498ad8a8f7e6486a0db046ad19f13
objective_c: 89e720c30d716b036faf9c9684022048eee1eee2
onnxruntime: f9b296392c96c42882be020a59dbeac6310d81b2
onnxruntime-c: a909204639a1f035f575127ac406f781ac797c9c
diff --git a/mobile/lib/ui/viewer/file/native_video_player_controls/play_pause_button.dart b/mobile/lib/ui/viewer/file/native_video_player_controls/play_pause_button.dart
index 06a1d40708..0b979402ae 100644
--- a/mobile/lib/ui/viewer/file/native_video_player_controls/play_pause_button.dart
+++ b/mobile/lib/ui/viewer/file/native_video_player_controls/play_pause_button.dart
@@ -1,3 +1,5 @@
+import "dart:async";
+
import "package:flutter/material.dart";
import "package:native_video_player/native_video_player.dart";
import "package:photos/theme/colors.dart";
@@ -13,20 +15,29 @@ class PlayPauseButton extends StatefulWidget {
class _PlayPauseButtonState extends State<PlayPauseButton> {
bool _isPlaying = true;
+ StreamSubscription<PlaybackEvent>? subscription;
+
@override
void initState() {
super.initState();
- widget.controller?.onPlaybackStatusChanged
- .addListener(_onPlaybackStatusChanged);
+ subscription = widget.controller?.events.listen(listen);
}
@override
void dispose() {
- widget.controller?.onPlaybackStatusChanged
- .removeListener(_onPlaybackStatusChanged);
+ subscription?.cancel();
super.dispose();
}
+ void listen(PlaybackEvent event) {
+ switch (event) {
+ case PlaybackStatusChangedEvent():
+ _onPlaybackStatusChanged();
+ break;
+ default:
+ }
+ }
+
@override
Widget build(BuildContext context) {
return GestureDetector(
@@ -74,8 +85,7 @@ class _PlayPauseButtonState extends State<PlayPauseButton> {
);
}
- PlaybackStatus? get _playbackStatus =>
- widget.controller?.playbackInfo?.status;
+ PlaybackStatus? get _playbackStatus => widget.controller?.playbackStatus;
void _onPlaybackStatusChanged() {
if (_playbackStatus == PlaybackStatus.playing) {
diff --git a/mobile/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart b/mobile/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
index dafd812db4..49e0e87d61 100644
--- a/mobile/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
+++ b/mobile/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
@@ -24,6 +24,8 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
const Duration(milliseconds: 100),
executionInterval: const Duration(milliseconds: 325),
);
+ StreamSubscription<void>? _eventsSubscription;
+
@override
void initState() {
super.initState();
@@ -33,11 +35,8 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
value: 0,
);
- widget.controller.onPlaybackStatusChanged.addListener(
- _onPlaybackStatusChanged,
- );
- widget.controller.onPlaybackPositionChanged.addListener(
- _onPlaybackPositionChanged,
+ _eventsSubscription = widget.controller.events.listen(
+ _listen,
);
_startMovingSeekbar();
@@ -45,13 +44,8 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
@override
void dispose() {
+ _eventsSubscription?.cancel();
_animationController.dispose();
- widget.controller.onPlaybackStatusChanged.removeListener(
- _onPlaybackStatusChanged,
- );
- widget.controller.onPlaybackPositionChanged.removeListener(
- _onPlaybackPositionChanged,
- );
_debouncer.cancelDebounceTimer();
super.dispose();
}
@@ -103,7 +97,8 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
void _seekTo(double value) {
_debouncer.run(() async {
unawaited(
- widget.controller.seekTo((value * widget.duration!).round()),
+ widget.controller
+ .seekTo((Duration(seconds: (value * widget.duration!).round()))),
);
});
}
@@ -133,19 +128,33 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
});
}
+ void _listen(PlaybackEvent playerData) {
+ switch (playerData) {
+ case PlaybackStatusChangedEvent():
+ // Emitted when playback status changes (playing, paused, or stopped)
+ _onPlaybackStatusChanged();
+ break;
+ case PlaybackPositionChangedEvent():
+ // Emitted when playback position changes
+ _onPlaybackPositionChanged();
+ break;
+ default:
+ }
+ }
+
void _onPlaybackStatusChanged() {
- if (widget.controller.playbackInfo?.status == PlaybackStatus.paused) {
+ if (widget.controller.playbackStatus == PlaybackStatus.paused) {
_animationController.stop();
}
}
void _onPlaybackPositionChanged() async {
- if (widget.controller.playbackInfo?.status == PlaybackStatus.paused ||
- (widget.controller.playbackInfo?.status == PlaybackStatus.stopped &&
- widget.controller.playbackInfo?.positionFraction != 0)) {
+ if (widget.controller.playbackStatus == PlaybackStatus.paused ||
+ (widget.controller.playbackStatus == PlaybackStatus.stopped &&
+ widget.controller.playbackPosition.inSeconds != 0)) {
return;
}
- final target = widget.controller.playbackInfo?.positionFraction ?? 0;
+ final target = widget.controller.playbackPosition.inMilliseconds;
//To immediately set the position to 0 when the video ends
if (_prevPositionFraction == 1.0 && target == 0.0) {
@@ -164,22 +173,26 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
await Future.delayed(const Duration(milliseconds: 450));
}
+ final duration = widget.controller.videoInfo?.durationInMilliseconds;
+ final double fractionTarget =
+ duration == null || duration <= 0 ? 0 : target / duration;
+
if (widget.duration != null) {
unawaited(
_animationController.animateTo(
- target + (1 / widget.duration!),
+ fractionTarget + (1 / widget.duration!),
duration: const Duration(seconds: 1),
),
);
} else {
unawaited(
_animationController.animateTo(
- target,
+ fractionTarget,
duration: const Duration(seconds: 1),
),
);
}
- _prevPositionFraction = target;
+ _prevPositionFraction = fractionTarget;
}
}
diff --git a/mobile/lib/ui/viewer/file/video_widget.dart b/mobile/lib/ui/viewer/file/video_widget.dart
index e93c353617..3fc6c1e8cf 100644
--- a/mobile/lib/ui/viewer/file/video_widget.dart
+++ b/mobile/lib/ui/viewer/file/video_widget.dart
@@ -1,15 +1,21 @@
import "dart:async";
+import "dart:io";
import "package:flutter/material.dart";
+import "package:fluttertoast/fluttertoast.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";
+import "package:photos/service_locator.dart";
import "package:photos/services/filedata/filedata_service.dart";
import "package:photos/services/preview_video_store.dart";
+import "package:photos/theme/colors.dart";
+import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/viewer/file/video_widget_media_kit_new.dart";
-import "package:photos/ui/viewer/file/video_widget_media_kit_preview.dart";
import "package:photos/ui/viewer/file/video_widget_native.dart";
+import "package:photos/utils/data_util.dart";
+import "package:photos/utils/toast_util.dart";
class VideoWidget extends StatefulWidget {
final EnteFile file;
@@ -32,6 +38,13 @@ class _VideoWidgetState extends State<VideoWidget> {
late final StreamSubscription<UseMediaKitForVideo>
useMediaKitForVideoSubscription;
late bool selectPreviewForPlay = widget.file.localID == null;
+ File? preview;
+ final player1 = GlobalKey();
+ final player2 = GlobalKey();
+ final player3 = GlobalKey();
+ final player4 = GlobalKey();
+
+ bool isPreviewLoadable = true;
@override
void initState() {
@@ -43,6 +56,7 @@ class _VideoWidgetState extends State<VideoWidget> {
useNativeVideoPlayer = false;
});
});
+ _checkForPreview();
}
@override
@@ -51,17 +65,88 @@ class _VideoWidgetState extends State<VideoWidget> {
super.dispose();
}
+ Future<void> _checkForPreview() async {
+ widget.playbackCallback?.call(false);
+ final data = await PreviewVideoStore.instance
+ .getPlaylist(widget.file)
+ .onError((error, stackTrace) {
+ if (!mounted) return;
+ _logger.warning("Failed to download preview video", error, stackTrace);
+ Fluttertoast.showToast(msg: "Failed to download preview!");
+ return null;
+ });
+ if (!mounted) return;
+ if (data != null) {
+ if (flagService.internalUser) {
+ final d =
+ FileDataService.instance.previewIds?[widget.file.uploadedFileID!];
+ if (d != null && widget.file.fileSize != null) {
+ // show toast with human readable size
+ final size = formatBytes(widget.file.fileSize!);
+ showToast(
+ context,
+ "[i] Preview OG Size ($size), previewSize: ${formatBytes(d.objectSize)}",
+ );
+ } else {
+ showShortToast(context, "Playing preview");
+ }
+ }
+ preview = data.preview;
+ } else {
+ isPreviewLoadable = false;
+ }
+ setState(() {});
+ }
+
@override
Widget build(BuildContext context) {
- final isPreviewVideoPlayable =
+ final isPreviewVideoPlayable = isPreviewLoadable &&
PreviewVideoStore.instance.isVideoStreamingEnabled &&
- widget.file.isUploaded &&
- (FileDataService.instance.previewIds
- ?.containsKey(widget.file.uploadedFileID!) ??
- false);
+ widget.file.isUploaded &&
+ (FileDataService.instance.previewIds
+ ?.containsKey(widget.file.uploadedFileID!) ??
+ false);
if (isPreviewVideoPlayable && selectPreviewForPlay) {
- return VideoWidgetMediaKitPreview(
+ if (preview == null) {
+ return Center(
+ child: Container(
+ width: 48,
+ height: 48,
+ padding: const EdgeInsets.all(8),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(24),
+ color: Colors.black.withOpacity(0.3),
+ border: Border.all(
+ color: strokeFaintDark,
+ width: 1,
+ ),
+ ),
+ child: const EnteLoadingWidget(
+ size: 32,
+ color: fillBaseDark,
+ padding: 0,
+ ),
+ ),
+ );
+ }
+ if (Platform.isAndroid) {
+ return VideoWidgetNative(
+ widget.file,
+ key: player1,
+ preview: preview,
+ tagPrefix: widget.tagPrefix,
+ playbackCallback: widget.playbackCallback,
+ onStreamChange: () {
+ setState(() {
+ selectPreviewForPlay = false;
+ });
+ },
+ );
+ }
+ return VideoWidgetMediaKitNew(
widget.file,
+ key: player2,
+ preview: preview,
tagPrefix: widget.tagPrefix,
playbackCallback: widget.playbackCallback,
onStreamChange: () {
@@ -75,6 +160,7 @@ class _VideoWidgetState extends State<VideoWidget> {
if (useNativeVideoPlayer) {
return VideoWidgetNative(
widget.file,
+ key: player3,
tagPrefix: widget.tagPrefix,
playbackCallback: widget.playbackCallback,
onStreamChange: () {
@@ -86,6 +172,7 @@ class _VideoWidgetState extends State<VideoWidget> {
} else {
return VideoWidgetMediaKitNew(
widget.file,
+ key: player4,
tagPrefix: widget.tagPrefix,
playbackCallback: widget.playbackCallback,
onStreamChange: () {
diff --git a/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart b/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
index 8edb1ac8cf..d483a061c0 100644
--- a/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
@@ -28,6 +28,7 @@ class VideoWidgetMediaKitNew extends StatefulWidget {
final Function(bool)? playbackCallback;
final bool isFromMemories;
final void Function() onStreamChange;
+ final File? preview;
const VideoWidgetMediaKitNew(
this.file, {
@@ -35,6 +36,7 @@ class VideoWidgetMediaKitNew extends StatefulWidget {
this.playbackCallback,
this.isFromMemories = false,
required this.onStreamChange,
+ this.preview,
super.key,
});
@@ -61,7 +63,9 @@ class _VideoWidgetMediaKitNewState extends State<VideoWidgetMediaKitNew>
);
super.initState();
WidgetsBinding.instance.addObserver(this);
- if (widget.file.isRemoteFile) {
+ if (widget.preview != null) {
+ _setVideoController(widget.preview!.path);
+ } else if (widget.file.isRemoteFile) {
_loadNetworkVideo();
_setFileSizeIfNull();
} else if (widget.file.isSharedMediaToAppSandbox) {
@@ -143,7 +147,7 @@ class _VideoWidgetMediaKitNewState extends State<VideoWidgetMediaKitNew>
widget.playbackCallback,
isFromMemories: widget.isFromMemories,
onStreamChange: widget.onStreamChange,
- isPreviewPlayer: false,
+ isPreviewPlayer: widget.preview != null,
)
: const Center(
child: EnteLoadingWidget(
diff --git a/mobile/lib/ui/viewer/file/video_widget_media_kit_preview.dart b/mobile/lib/ui/viewer/file/video_widget_media_kit_preview.dart
deleted file mode 100644
index 46f569660c..0000000000
--- a/mobile/lib/ui/viewer/file/video_widget_media_kit_preview.dart
+++ /dev/null
@@ -1,173 +0,0 @@
-import "dart:async";
-
-import "package:flutter/material.dart";
-import "package:fluttertoast/fluttertoast.dart";
-import "package:logging/logging.dart";
-import "package:media_kit/media_kit.dart";
-import "package:media_kit_video/media_kit_video.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/models/file/file.dart";
-import "package:photos/service_locator.dart";
-import "package:photos/services/filedata/filedata_service.dart";
-import "package:photos/services/preview_video_store.dart";
-import "package:photos/theme/colors.dart";
-import "package:photos/ui/actions/file/file_actions.dart";
-import "package:photos/ui/common/loading_widget.dart";
-import "package:photos/ui/viewer/file/video_widget_media_kit_common.dart"
- as common;
-import "package:photos/utils/data_util.dart";
-import "package:photos/utils/file_util.dart";
-import "package:photos/utils/toast_util.dart";
-
-class VideoWidgetMediaKitPreview extends StatefulWidget {
- final EnteFile file;
- final String? tagPrefix;
- final Function(bool)? playbackCallback;
- final bool isFromMemories;
- final void Function() onStreamChange;
-
- const VideoWidgetMediaKitPreview(
- this.file, {
- this.tagPrefix,
- this.playbackCallback,
- this.isFromMemories = false,
- required this.onStreamChange,
- super.key,
- });
-
- @override
- State<VideoWidgetMediaKitPreview> createState() =>
- _VideoWidgetMediaKitPreviewState();
-}
-
-class _VideoWidgetMediaKitPreviewState extends State<VideoWidgetMediaKitPreview>
- with WidgetsBindingObserver {
- final Logger _logger = Logger("VideoWidgetMediaKitNew");
- late final player = Player();
- VideoController? controller;
- final _progressNotifier = ValueNotifier<double?>(null);
- bool _isAppInFG = true;
- late StreamSubscription<PauseVideoEvent> pauseVideoSubscription;
- bool isGuestView = false;
- late final StreamSubscription<GuestViewEvent> _guestViewEventSubscription;
- bool _isGuestView = false;
-
- @override
- void initState() {
- _logger.info(
- 'initState for ${widget.file.generatedID} with tag ${widget.file.tag} and name ${widget.file.displayName}',
- );
- super.initState();
- WidgetsBinding.instance.addObserver(this);
- _checkForPreview();
-
- pauseVideoSubscription = Bus.instance.on<PauseVideoEvent>().listen((event) {
- player.pause();
- });
- _guestViewEventSubscription =
- Bus.instance.on<GuestViewEvent>().listen((event) {
- setState(() {
- _isGuestView = event.isGuestView;
- });
- });
- }
-
- Future<void> _checkForPreview() async {
- widget.playbackCallback?.call(false);
- final data = await PreviewVideoStore.instance
- .getPlaylist(widget.file)
- .onError((error, stackTrace) {
- if (!mounted) return;
- _logger.warning("Failed to download preview video", error, stackTrace);
- Fluttertoast.showToast(msg: "Failed to download preview!");
- return null;
- });
- if (!mounted) return;
- if (data != null) {
- if (flagService.internalUser) {
- final d =
- FileDataService.instance.previewIds?[widget.file.uploadedFileID!];
- if (d != null && widget.file.fileSize != null) {
- // show toast with human readable size
- final size = formatBytes(widget.file.fileSize!);
- showToast(
- context,
- "[i] Preview OG Size ($size), previewSize: ${formatBytes(d.objectSize)}",
- );
- } else {
- showShortToast(context, "Playing preview");
- }
- }
- _setVideoController(data.preview.path);
- }
- }
-
- @override
- void didChangeAppLifecycleState(AppLifecycleState state) {
- if (state == AppLifecycleState.resumed) {
- _isAppInFG = true;
- } else {
- _isAppInFG = false;
- }
- }
-
- @override
- void dispose() {
- _guestViewEventSubscription.cancel();
- pauseVideoSubscription.cancel();
- removeCallBack(widget.file);
- _progressNotifier.dispose();
- WidgetsBinding.instance.removeObserver(this);
- player.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onVerticalDragUpdate: _isGuestView
- ? null
- : (d) => {
- if (d.delta.dy > dragSensitivity)
- {
- Navigator.of(context).pop(),
- }
- else if (d.delta.dy < (dragSensitivity * -1))
- {
- showDetailsSheet(context, widget.file),
- },
- },
- child: Center(
- child: controller != null
- ? common.VideoWidget(
- widget.file,
- controller!,
- widget.playbackCallback,
- isFromMemories: widget.isFromMemories,
- onStreamChange: widget.onStreamChange,
- isPreviewPlayer: true,
- )
- : const Center(
- child: EnteLoadingWidget(
- size: 32,
- color: fillBaseDark,
- padding: 0,
- ),
- ),
- ),
- );
- }
-
- void _setVideoController(String url) {
- if (mounted) {
- setState(() {
- player.setPlaylistMode(PlaylistMode.single);
- controller = VideoController(player);
- player.open(Media(url), play: _isAppInFG);
- });
- }
- }
-}
diff --git a/mobile/lib/ui/viewer/file/video_widget_native.dart b/mobile/lib/ui/viewer/file/video_widget_native.dart
index c3d1bb8c83..ebee67c8f0 100644
--- a/mobile/lib/ui/viewer/file/video_widget_native.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_native.dart
@@ -38,6 +38,8 @@ class VideoWidgetNative extends StatefulWidget {
final Function(bool)? playbackCallback;
final bool isFromMemories;
final void Function()? onStreamChange;
+ final File? preview;
+
const VideoWidgetNative(
this.file, {
this.tagPrefix,
@@ -45,6 +47,7 @@ class VideoWidgetNative extends StatefulWidget {
this.isFromMemories = false,
required this.onStreamChange,
super.key,
+ this.preview,
});
@override
@@ -70,6 +73,8 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
final _isSeeking = ValueNotifier(false);
final _debouncer = Debouncer(const Duration(milliseconds: 2000));
final _elTooltipController = ElTooltipController();
+ StreamSubscription<PlaybackEvent>? _subscription;
+ int position = 0;
@override
void initState() {
@@ -78,7 +83,9 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
);
super.initState();
WidgetsBinding.instance.addObserver(this);
- if (widget.file.isRemoteFile) {
+ if (widget.preview != null) {
+ _setFilePathForNativePlayer(widget.preview!.path);
+ } else if (widget.file.isRemoteFile) {
_loadNetworkVideo();
_setFileSizeIfNull();
} else if (widget.file.isSharedMediaToAppSandbox) {
@@ -120,7 +127,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state != AppLifecycleState.resumed) {
- if (_controller?.playbackInfo?.status == PlaybackStatus.playing) {
+ if (_controller?.playbackStatus == PlaybackStatus.playing) {
_controller?.pause();
}
}
@@ -148,11 +155,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
removeCallBack(widget.file);
_progressNotifier.dispose();
WidgetsBinding.instance.removeObserver(this);
- _controller?.onPlaybackEnded.removeListener(_onPlaybackEnded);
- _controller?.onPlaybackReady.removeListener(_onPlaybackReady);
- _controller?.onError.removeListener(_onError);
- _controller?.onPlaybackStatusChanged
- .removeListener(_onPlaybackStatusChanged);
+ _subscription?.cancel();
_isPlaybackReady.dispose();
_showControls.dispose();
_isSeeking.removeListener(_seekListener);
@@ -286,6 +289,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
return PreviewStatusWidget(
showControls: value,
file: widget.file,
+ isPreviewPlayer: widget.preview != null,
onStreamChange: widget.onStreamChange,
);
},
@@ -306,6 +310,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
duration: duration,
showControls: _showControls,
isSeeking: _isSeeking,
+ position: position,
)
: const SizedBox();
},
@@ -332,17 +337,15 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
);
_controller = controller;
- controller.onError.addListener(_onError);
- controller.onPlaybackEnded.addListener(_onPlaybackEnded);
- controller.onPlaybackReady.addListener(_onPlaybackReady);
- controller.onPlaybackStatusChanged.addListener(_onPlaybackStatusChanged);
+ _subscription = controller.events.listen(_listen);
+
_isSeeking.addListener(_seekListener);
- final videoSource = await VideoSource.init(
+ final videoSource = VideoSource(
path: _filePath!,
type: VideoSourceType.file,
);
- await controller.loadVideoSource(videoSource);
+ await controller.loadVideo(videoSource);
} catch (e) {
_logger.severe(
"Error initializing native video player controller for file gen id: ${widget.file.generatedID}",
@@ -351,13 +354,34 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
}
}
+ void _listen(PlaybackEvent event) {
+ switch (event) {
+ case PlaybackStatusChangedEvent():
+ _onPlaybackStatusChanged();
+ case PlaybackReadyEvent():
+ _onPlaybackReady();
+ break;
+ case PlaybackPositionChangedEvent():
+ position = event.positionInMilliseconds;
+ setState(() {});
+ break;
+ case PlaybackEndedEvent():
+ _onPlaybackEnded();
+ break;
+ case PlaybackErrorEvent():
+ _onError(event.errorMessage);
+ break;
+ default:
+ }
+ }
+
void _seekListener() {
if (!_isSeeking.value &&
- _controller?.playbackInfo?.status == PlaybackStatus.playing) {
+ _controller?.playbackStatus == PlaybackStatus.playing) {
_debouncer.run(() async {
if (mounted) {
if (_isSeeking.value ||
- _controller?.playbackInfo?.status != PlaybackStatus.playing) {
+ _controller?.playbackStatus != PlaybackStatus.playing) {
return;
}
_showControls.value = false;
@@ -370,15 +394,17 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
}
void _onPlaybackStatusChanged() {
- if (_isSeeking.value || _controller?.playbackInfo?.positionFraction == 1) {
+ if (_isSeeking.value ||
+ _controller?.playbackPosition.inMilliseconds ==
+ _controller?.videoInfo?.durationInMilliseconds) {
return;
}
- if (_controller!.playbackInfo?.status == PlaybackStatus.playing) {
+ if (_controller!.playbackStatus == PlaybackStatus.playing) {
if (mounted) {
_debouncer.run(() async {
if (mounted) {
if (_isSeeking.value ||
- _controller!.playbackInfo?.status != PlaybackStatus.playing) {
+ _controller!.playbackStatus != PlaybackStatus.playing) {
return;
}
_showControls.value = false;
@@ -395,12 +421,12 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
}
}
- void _onError() {
+ void _onError(String errorMessage) {
//This doesn't work all the time
_logger.severe(
"Error in native video player controller for file gen id: ${widget.file.generatedID}",
);
- _logger.severe(_controller!.onError.value);
+ _logger.severe(errorMessage);
Bus.instance.fire(UseMediaKitForVideo());
}
@@ -555,12 +581,14 @@ class _SeekBarAndDuration extends StatelessWidget {
final String? duration;
final ValueNotifier<bool> showControls;
final ValueNotifier<bool> isSeeking;
+ final int position;
const _SeekBarAndDuration({
required this.controller,
required this.duration,
required this.showControls,
required this.isSeeking,
+ required this.position,
});
@override
@@ -608,22 +636,13 @@ class _SeekBarAndDuration extends StatelessWidget {
seconds: 5,
),
curve: Curves.easeInOut,
- child: ValueListenableBuilder(
- valueListenable: controller!.onPlaybackPositionChanged,
- builder: (
- BuildContext context,
- int value,
- _,
- ) {
- return Text(
- secondsToDuration(value),
- style: getEnteTextTheme(
- context,
- ).mini.copyWith(
- color: textBaseDark,
- ),
- );
- },
+ child: Text(
+ secondsToDuration(position ~/ 1000),
+ style: getEnteTextTheme(
+ context,
+ ).mini.copyWith(
+ color: textBaseDark,
+ ),
),
),
Expanded(
diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock
index 286c154ba7..fb7b9beb6a 100644
--- a/mobile/pubspec.lock
+++ b/mobile/pubspec.lock
@@ -1756,12 +1756,11 @@ packages:
native_video_player:
dependency: "direct main"
description:
- path: "."
- ref: notify_if_video_isnt_playable
- resolved-ref: dd09ee801939372ca3d1a504a9dbd576d4bf6dcf
- url: "https://github.com/ashilkn/native_video_player.git"
- source: git
- version: "1.3.1"
+ name: native_video_player
+ sha256: "5a56da17e6c359de8e8063281dc14c1f8a3f17d40220cdbb1fa69217a2dda8b2"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.0-dev.3"
nested:
dependency: transitive
description:
@@ -1903,10 +1902,10 @@ packages:
dependency: "direct main"
description:
name: path_provider
- sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
+ sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
- version: "2.1.4"
+ version: "2.1.5"
path_provider_android:
dependency: transitive
description:
diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml
index 7e480d60da..42aca33e20 100644
--- a/mobile/pubspec.yaml
+++ b/mobile/pubspec.yaml
@@ -145,10 +145,7 @@ dependencies:
move_to_background: ^1.0.2
nanoid: ^1.0.0
native_dio_adapter: ^1.4.0
- native_video_player:
- git:
- url: https://github.com/ashilkn/native_video_player.git
- ref: notify_if_video_isnt_playable
+ native_video_player: ^3.0.0-dev.3
onnx_dart:
path: plugins/onnx_dart
onnxruntime: