Add loop control in video player

This commit is contained in:
Ming Ming 2022-12-26 11:32:29 +08:00
parent c48492597e
commit 22fd922125
3 changed files with 68 additions and 9 deletions

View file

@ -1497,6 +1497,10 @@
"@initialSyncMessage": {
"description": "After adding a new account, the app need to sync with the server before showing anything. This message will be shown on screen instead with a proper progress bar and the folder being synced."
},
"loopTooltip": "Loop",
"@loopTooltip": {
"description": "Enable or disable loop in the video player"
},
"errorUnauthenticated": "Unauthenticated access. Please sign-in again if the problem continues",
"@errorUnauthenticated": {

View file

@ -181,6 +181,7 @@
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage",
"loopTooltip",
"errorAlbumDowngrade"
],
@ -378,6 +379,7 @@
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage",
"loopTooltip",
"errorAlbumDowngrade"
],
@ -465,13 +467,15 @@
"imageSaveOptionDialogContent",
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
],
"es": [
"connectingToServerInstruction",
"settingsEnhanceMaxResolutionTitle2",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
],
"fi": [
@ -481,7 +485,8 @@
"settingsSeedColorTitle",
"settingsSeedColorDescription",
"settingsSeedColorPickerTitle",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
],
"fr": [
@ -588,7 +593,8 @@
"imageSaveOptionDialogContent",
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
],
"pl": [
@ -712,7 +718,8 @@
"imageSaveOptionDialogContent",
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
],
"pt": [
@ -815,7 +822,8 @@
"imageSaveOptionDialogContent",
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
],
"ru": [
@ -918,7 +926,8 @@
"imageSaveOptionDialogContent",
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
],
"zh": [
@ -1021,7 +1030,8 @@
"imageSaveOptionDialogContent",
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
],
"zh_Hant": [
@ -1124,6 +1134,7 @@
"imageSaveOptionDialogContent",
"imageSaveOptionDialogDeviceButtonLabel",
"imageSaveOptionDialogServerButtonLabel",
"initialSyncMessage"
"initialSyncMessage",
"loopTooltip"
]
}

View file

@ -213,6 +213,7 @@ class _VideoViewerState extends State<VideoViewer>
),
),
const SizedBox(width: 4),
_LoopToggle(controller: _controller),
Tooltip(
message: _controller.value.volume == 0
? L10n.global().unmuteTooltip
@ -311,6 +312,49 @@ class _VideoViewerState extends State<VideoViewer>
var _isFinished = false;
}
class _LoopToggle extends StatefulWidget {
const _LoopToggle({
required this.controller,
});
@override
State<StatefulWidget> createState() => _LoopToggleState();
final VideoPlayerController controller;
}
class _LoopToggleState extends State<_LoopToggle> {
@override
Widget build(BuildContext context) {
return Tooltip(
message: L10n.global().loopTooltip,
child: InkWell(
borderRadius: const BorderRadius.all(Radius.circular(32)),
onTap: () {
setState(() {
widget.controller.setLooping(!widget.controller.value.isLooping);
});
},
child: Padding(
padding: const EdgeInsets.all(4),
child: AnimatedSwitcher(
duration: k.animationDurationNormal,
child: widget.controller.value.isLooping
? const Icon(
Icons.loop,
key: Key("loop_on"),
)
: const Icon(
Icons.sync_disabled,
key: Key("loop_off"),
),
),
),
),
);
}
}
String _durationToString(Duration duration) {
String product = "";
if (duration.inHours > 0) {