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": { "@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." "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": "Unauthenticated access. Please sign-in again if the problem continues",
"@errorUnauthenticated": { "@errorUnauthenticated": {

View file

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

View file

@ -213,6 +213,7 @@ class _VideoViewerState extends State<VideoViewer>
), ),
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
_LoopToggle(controller: _controller),
Tooltip( Tooltip(
message: _controller.value.volume == 0 message: _controller.value.volume == 0
? L10n.global().unmuteTooltip ? L10n.global().unmuteTooltip
@ -311,6 +312,49 @@ class _VideoViewerState extends State<VideoViewer>
var _isFinished = false; 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 _durationToString(Duration duration) {
String product = ""; String product = "";
if (duration.inHours > 0) { if (duration.inHours > 0) {