From 09c0b63c053015daf4e4029bae86c3ffe8d4ae44 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Sun, 2 Oct 2022 20:54:20 +0200 Subject: [PATCH] video: option for muted auto play --- CHANGELOG.md | 1 + lib/l10n/app_de.arb | 8 ++-- lib/l10n/app_el.arb | 8 ++-- lib/l10n/app_en.arb | 9 ++-- lib/l10n/app_es.arb | 8 ++-- lib/l10n/app_fr.arb | 8 ++-- lib/l10n/app_id.arb | 8 ++-- lib/l10n/app_it.arb | 8 ++-- lib/l10n/app_ja.arb | 8 ++-- lib/l10n/app_ko.arb | 8 ++-- lib/l10n/app_nl.arb | 8 ++-- lib/l10n/app_pt.arb | 8 ++-- lib/l10n/app_ru.arb | 8 ++-- lib/l10n/app_tr.arb | 2 +- lib/l10n/app_zh.arb | 8 ++-- lib/model/settings/defaults.dart | 2 +- lib/model/settings/enums/enums.dart | 2 + .../enums/slideshow_video_playback.dart | 6 +-- .../settings/enums/video_auto_play_mode.dart | 17 ++++++++ lib/model/settings/settings.dart | 8 ++-- lib/widgets/settings/video/video.dart | 13 +++--- .../viewer/visual/controller_mixin.dart | 42 +++++++++++++++---- untranslated.json | 25 +++++++++-- 23 files changed, 147 insertions(+), 76 deletions(-) create mode 100644 lib/model/settings/enums/video_auto_play_mode.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index abcaf3736..c3d022906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - Info: improved display for XMP - Stats: top albums - Stats: open full top listings +- Video: option for muted auto play - Slideshow: option for no transition - Widget: tap action setting - Wallpaper: scroll effect option diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index d8b17493d..42187473e 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -155,9 +155,9 @@ "displayRefreshRatePreferHighest": "Höchste Rate", "displayRefreshRatePreferLowest": "Niedrigste Rate", - "slideshowVideoPlaybackSkip": "Überspringen", - "slideshowVideoPlaybackMuted": "Stumm abspielen", - "slideshowVideoPlaybackWithSound": "Mit Ton abspielen", + "videoPlaybackSkip": "Überspringen", + "videoPlaybackMuted": "Stumm abspielen", + "videoPlaybackWithSound": "Mit Ton abspielen", "themeBrightnessLight": "Hell", "themeBrightnessDark": "Dunkel", @@ -535,7 +535,7 @@ "settingsVideoSectionTitle": "Video", "settingsVideoShowVideos": "Videos anzeigen", "settingsVideoEnableHardwareAcceleration": "Hardware-Beschleunigung", - "settingsVideoEnableAutoPlay": "Automatische Wiedergabe", + "settingsVideoAutoPlay": "Automatische Wiedergabe", "settingsVideoLoopModeTile": "Schleifen-Modus", "settingsVideoLoopModeDialogTitle": "Schleifen-Modus", diff --git a/lib/l10n/app_el.arb b/lib/l10n/app_el.arb index f00605985..7435e7bee 100644 --- a/lib/l10n/app_el.arb +++ b/lib/l10n/app_el.arb @@ -155,9 +155,9 @@ "displayRefreshRatePreferHighest": "Υψηλότερος ρυθμός", "displayRefreshRatePreferLowest": "Χαμηλότερος ρυθμός", - "slideshowVideoPlaybackSkip": "Παράλειψη", - "slideshowVideoPlaybackMuted": "Αναπαραγωγή σε σίγαση", - "slideshowVideoPlaybackWithSound": "Αναπαραγωγή με ήχο", + "videoPlaybackSkip": "Παράλειψη", + "videoPlaybackMuted": "Αναπαραγωγή σε σίγαση", + "videoPlaybackWithSound": "Αναπαραγωγή με ήχο", "themeBrightnessLight": "Φωτεινό", "themeBrightnessDark": "Σκούρο", @@ -535,7 +535,7 @@ "settingsVideoSectionTitle": "Βιντεο", "settingsVideoShowVideos": "Εμφάνιση των βίντεο στη συλλογή", "settingsVideoEnableHardwareAcceleration": "Επιτάχυνση υλισμικού", - "settingsVideoEnableAutoPlay": "Αυτόματη αναπαραγωγή κατά το άνοιγμα", + "settingsVideoAutoPlay": "Αυτόματη αναπαραγωγή κατά το άνοιγμα", "settingsVideoLoopModeTile": "Επανάληψη αυτόματα στο τέλος κάθε βίντεο", "settingsVideoLoopModeDialogTitle": "Επαναληψη Αυτοματα στο Τελος Καθε Βιντεο", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index b241fc639..ffbb38eea 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -197,9 +197,9 @@ "displayRefreshRatePreferHighest": "Highest rate", "displayRefreshRatePreferLowest": "Lowest rate", - "slideshowVideoPlaybackSkip": "Skip", - "slideshowVideoPlaybackMuted": "Play muted", - "slideshowVideoPlaybackWithSound": "Play with sound", + "videoPlaybackSkip": "Skip", + "videoPlaybackMuted": "Play muted", + "videoPlaybackWithSound": "Play with sound", "themeBrightnessLight": "Light", "themeBrightnessDark": "Dark", @@ -632,6 +632,7 @@ "settingsPageTitle": "Settings", "settingsSystemDefault": "System", "settingsDefault": "Default", + "settingsDisabled": "Disabled", "settingsSearchFieldLabel": "Search settings", "settingsSearchEmpty": "No matching setting", @@ -725,7 +726,7 @@ "settingsVideoSectionTitle": "Video", "settingsVideoShowVideos": "Show videos", "settingsVideoEnableHardwareAcceleration": "Hardware acceleration", - "settingsVideoEnableAutoPlay": "Auto play", + "settingsVideoAutoPlay": "Auto play", "settingsVideoLoopModeTile": "Loop mode", "settingsVideoLoopModeDialogTitle": "Loop Mode", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index e84adbb27..354d473d3 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -151,9 +151,9 @@ "displayRefreshRatePreferHighest": "Alta tasa", "displayRefreshRatePreferLowest": "Baja tasa", - "slideshowVideoPlaybackSkip": "Saltear", - "slideshowVideoPlaybackMuted": "Reproducir sin sonido", - "slideshowVideoPlaybackWithSound": "Reproducir con sonido", + "videoPlaybackSkip": "Saltear", + "videoPlaybackMuted": "Reproducir sin sonido", + "videoPlaybackWithSound": "Reproducir con sonido", "themeBrightnessLight": "Claro", "themeBrightnessDark": "Obscuro", @@ -519,7 +519,7 @@ "settingsVideoSectionTitle": "Video", "settingsVideoShowVideos": "Mostrar videos", "settingsVideoEnableHardwareAcceleration": "Aceleración por hardware", - "settingsVideoEnableAutoPlay": "Reproducción automática", + "settingsVideoAutoPlay": "Reproducción automática", "settingsVideoLoopModeTile": "Modo bucle", "settingsVideoLoopModeDialogTitle": "Modo bucle", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 9b918573c..c7a632f7b 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -157,9 +157,9 @@ "displayRefreshRatePreferHighest": "Fréquence maximale", "displayRefreshRatePreferLowest": "Fréquence minimale", - "slideshowVideoPlaybackSkip": "Passer", - "slideshowVideoPlaybackMuted": "Jouer sans son", - "slideshowVideoPlaybackWithSound": "Jouer avec son", + "videoPlaybackSkip": "Passer", + "videoPlaybackMuted": "Jouer sans son", + "videoPlaybackWithSound": "Jouer avec son", "themeBrightnessLight": "Clair", "themeBrightnessDark": "Sombre", @@ -545,7 +545,7 @@ "settingsVideoSectionTitle": "Vidéo", "settingsVideoShowVideos": "Afficher les vidéos", "settingsVideoEnableHardwareAcceleration": "Accélération matérielle", - "settingsVideoEnableAutoPlay": "Lecture automatique", + "settingsVideoAutoPlay": "Lecture automatique", "settingsVideoLoopModeTile": "Lecture répétée", "settingsVideoLoopModeDialogTitle": "Lecture répétée", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 50b866d50..ab86e0068 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -155,9 +155,9 @@ "displayRefreshRatePreferHighest": "Penyegaran tertinggi", "displayRefreshRatePreferLowest": "Penyegaran terendah", - "slideshowVideoPlaybackSkip": "Lewati", - "slideshowVideoPlaybackMuted": "Mainkan bisu", - "slideshowVideoPlaybackWithSound": "Mainkan dengan suara", + "videoPlaybackSkip": "Lewati", + "videoPlaybackMuted": "Mainkan bisu", + "videoPlaybackWithSound": "Mainkan dengan suara", "themeBrightnessLight": "Terang", "themeBrightnessDark": "Gelap", @@ -535,7 +535,7 @@ "settingsVideoSectionTitle": "Video", "settingsVideoShowVideos": "Tampilkan video", "settingsVideoEnableHardwareAcceleration": "Akselerasi perangkat keras", - "settingsVideoEnableAutoPlay": "Putar otomatis", + "settingsVideoAutoPlay": "Putar otomatis", "settingsVideoLoopModeTile": "Putar ulang", "settingsVideoLoopModeDialogTitle": "Putar Ulang", diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index c2fe6374a..6938c076a 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -155,9 +155,9 @@ "displayRefreshRatePreferHighest": "Frequenza massima", "displayRefreshRatePreferLowest": "Frequenza minima", - "slideshowVideoPlaybackSkip": "Salta", - "slideshowVideoPlaybackMuted": "Riproduci senza audio", - "slideshowVideoPlaybackWithSound": "Riproduci con audio", + "videoPlaybackSkip": "Salta", + "videoPlaybackMuted": "Riproduci senza audio", + "videoPlaybackWithSound": "Riproduci con audio", "themeBrightnessLight": "Chiaro", "themeBrightnessDark": "Scuro", @@ -534,7 +534,7 @@ "settingsVideoSectionTitle": "Video", "settingsVideoShowVideos": "Mostra video", "settingsVideoEnableHardwareAcceleration": "Accelerazione hardware", - "settingsVideoEnableAutoPlay": "Riproduzione automatica", + "settingsVideoAutoPlay": "Riproduzione automatica", "settingsVideoLoopModeTile": "Modalità loop", "settingsVideoLoopModeDialogTitle": "Modalità loop", diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index a65a58789..bbd1f3f57 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -151,9 +151,9 @@ "displayRefreshRatePreferHighest": "高レート", "displayRefreshRatePreferLowest": "低レート", - "slideshowVideoPlaybackSkip": "スキップ", - "slideshowVideoPlaybackMuted": "ミュート再生", - "slideshowVideoPlaybackWithSound": "音声あり再生", + "videoPlaybackSkip": "スキップ", + "videoPlaybackMuted": "ミュート再生", + "videoPlaybackWithSound": "音声あり再生", "themeBrightnessLight": "ライト", "themeBrightnessDark": "ダーク", @@ -518,7 +518,7 @@ "settingsVideoSectionTitle": "動画", "settingsVideoShowVideos": "動画を表示", "settingsVideoEnableHardwareAcceleration": "ハードウェア アクセラレーション", - "settingsVideoEnableAutoPlay": "自動再生", + "settingsVideoAutoPlay": "自動再生", "settingsVideoLoopModeTile": "ループ モード", "settingsVideoLoopModeDialogTitle": "ループ モード", diff --git a/lib/l10n/app_ko.arb b/lib/l10n/app_ko.arb index d456f9b58..9f0ab9950 100644 --- a/lib/l10n/app_ko.arb +++ b/lib/l10n/app_ko.arb @@ -157,9 +157,9 @@ "displayRefreshRatePreferHighest": "가장 높은 재생률", "displayRefreshRatePreferLowest": "가장 낮은 재생률", - "slideshowVideoPlaybackSkip": "생략", - "slideshowVideoPlaybackMuted": "음소거 재생", - "slideshowVideoPlaybackWithSound": "일반 재생", + "videoPlaybackSkip": "생략", + "videoPlaybackMuted": "음소거 재생", + "videoPlaybackWithSound": "일반 재생", "themeBrightnessLight": "라이트", "themeBrightnessDark": "다크", @@ -545,7 +545,7 @@ "settingsVideoSectionTitle": "동영상", "settingsVideoShowVideos": "미디어에 동영상 표시", "settingsVideoEnableHardwareAcceleration": "하드웨어 가속", - "settingsVideoEnableAutoPlay": "자동 재생", + "settingsVideoAutoPlay": "자동 재생", "settingsVideoLoopModeTile": "반복 모드", "settingsVideoLoopModeDialogTitle": "반복 모드", diff --git a/lib/l10n/app_nl.arb b/lib/l10n/app_nl.arb index 4105b5218..f65b15a4d 100644 --- a/lib/l10n/app_nl.arb +++ b/lib/l10n/app_nl.arb @@ -155,9 +155,9 @@ "displayRefreshRatePreferHighest": "Hoogste waardering", "displayRefreshRatePreferLowest": "Laagste waardering", - "slideshowVideoPlaybackSkip": "Overslaan", - "slideshowVideoPlaybackMuted": "Gedempte afspelen", - "slideshowVideoPlaybackWithSound": "Met geluid afspelen", + "videoPlaybackSkip": "Overslaan", + "videoPlaybackMuted": "Gedempte afspelen", + "videoPlaybackWithSound": "Met geluid afspelen", "themeBrightnessLight": "Licht", "themeBrightnessDark": "Donker", @@ -535,7 +535,7 @@ "settingsVideoSectionTitle": "Video", "settingsVideoShowVideos": "Videos", "settingsVideoEnableHardwareAcceleration": "Hardware acceleratie", - "settingsVideoEnableAutoPlay": "Automatisch afspelen", + "settingsVideoAutoPlay": "Automatisch afspelen", "settingsVideoLoopModeTile": "Herhaald afspelen", "settingsVideoLoopModeDialogTitle": "Herhaald afspelen", diff --git a/lib/l10n/app_pt.arb b/lib/l10n/app_pt.arb index f7bf0df0c..214bbefae 100644 --- a/lib/l10n/app_pt.arb +++ b/lib/l10n/app_pt.arb @@ -155,9 +155,9 @@ "displayRefreshRatePreferHighest": "Taxa mais alta", "displayRefreshRatePreferLowest": "Taxa mais baixa", - "slideshowVideoPlaybackSkip": "Pular", - "slideshowVideoPlaybackMuted": "Reproduzir sem som", - "slideshowVideoPlaybackWithSound": "Reproduzir com som", + "videoPlaybackSkip": "Pular", + "videoPlaybackMuted": "Reproduzir sem som", + "videoPlaybackWithSound": "Reproduzir com som", "themeBrightnessLight": "Claro", "themeBrightnessDark": "Escuro", @@ -535,7 +535,7 @@ "settingsVideoSectionTitle": "Vídeo", "settingsVideoShowVideos": "Mostrar vídeos", "settingsVideoEnableHardwareAcceleration": "Aceleraçao do hardware", - "settingsVideoEnableAutoPlay": "Reprodução automática", + "settingsVideoAutoPlay": "Reprodução automática", "settingsVideoLoopModeTile": "Modo de loop", "settingsVideoLoopModeDialogTitle": "Modo de loop", diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index d6c29cb27..57b839bb4 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -155,9 +155,9 @@ "displayRefreshRatePreferHighest": "Наивысшая частота", "displayRefreshRatePreferLowest": "Наименьшая частота", - "slideshowVideoPlaybackSkip": "Пропустить", - "slideshowVideoPlaybackMuted": "Играть без звука", - "slideshowVideoPlaybackWithSound": "Играть со звуком", + "videoPlaybackSkip": "Пропустить", + "videoPlaybackMuted": "Играть без звука", + "videoPlaybackWithSound": "Играть со звуком", "themeBrightnessLight": "Светлая", "themeBrightnessDark": "Тёмная", @@ -535,7 +535,7 @@ "settingsVideoSectionTitle": "Видео", "settingsVideoShowVideos": "Показать видео", "settingsVideoEnableHardwareAcceleration": "Аппаратное ускорение", - "settingsVideoEnableAutoPlay": "Автозапуск воспроизведения", + "settingsVideoAutoPlay": "Автозапуск воспроизведения", "settingsVideoLoopModeTile": "Циклический режим", "settingsVideoLoopModeDialogTitle": "Цикличный режим", diff --git a/lib/l10n/app_tr.arb b/lib/l10n/app_tr.arb index 1dc670844..13237729f 100644 --- a/lib/l10n/app_tr.arb +++ b/lib/l10n/app_tr.arb @@ -502,7 +502,7 @@ "settingsVideoSectionTitle": "Video", "settingsVideoShowVideos": "Videoları göster", "settingsVideoEnableHardwareAcceleration": "Donanım hızlandırma", - "settingsVideoEnableAutoPlay": "Otomatik oynat", + "settingsVideoAutoPlay": "Otomatik oynat", "settingsVideoLoopModeTile": "Döngü modu", "settingsVideoLoopModeDialogTitle": "Döngü Modu", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 539f42cd0..273af2ae0 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -155,9 +155,9 @@ "displayRefreshRatePreferHighest": "最高刷新率", "displayRefreshRatePreferLowest": "最低刷新率", - "slideshowVideoPlaybackSkip": "跳过", - "slideshowVideoPlaybackMuted": "静音播放", - "slideshowVideoPlaybackWithSound": "带音播放", + "videoPlaybackSkip": "跳过", + "videoPlaybackMuted": "静音播放", + "videoPlaybackWithSound": "带音播放", "themeBrightnessLight": "浅色", "themeBrightnessDark": "深色", @@ -535,7 +535,7 @@ "settingsVideoSectionTitle": "视频", "settingsVideoShowVideos": "显示视频", "settingsVideoEnableHardwareAcceleration": "硬件加速", - "settingsVideoEnableAutoPlay": "自动播放", + "settingsVideoAutoPlay": "自动播放", "settingsVideoLoopModeTile": "循环模式", "settingsVideoLoopModeDialogTitle": "循环模式", diff --git a/lib/model/settings/defaults.dart b/lib/model/settings/defaults.dart index 602a067b8..a4e8b8808 100644 --- a/lib/model/settings/defaults.dart +++ b/lib/model/settings/defaults.dart @@ -89,7 +89,7 @@ class SettingsDefaults { // video static const enableVideoHardwareAcceleration = true; - static const enableVideoAutoPlay = false; + static const videoAutoPlayMode = VideoAutoPlayMode.disabled; static const videoLoopMode = VideoLoopMode.shortOnly; static const videoShowRawTimedText = false; static const videoControls = VideoControls.play; diff --git a/lib/model/settings/enums/enums.dart b/lib/model/settings/enums/enums.dart index 926bbdb11..79f4cc1e7 100644 --- a/lib/model/settings/enums/enums.dart +++ b/lib/model/settings/enums/enums.dart @@ -28,6 +28,8 @@ enum VideoControls { play, playSeek, playOutside, none } enum VideoLoopMode { never, shortOnly, always } +enum VideoAutoPlayMode { disabled, playMuted, playWithSound } + enum ViewerTransition { slide, parallax, fade, zoomIn, none } enum WidgetOpenPage { home, viewer } diff --git a/lib/model/settings/enums/slideshow_video_playback.dart b/lib/model/settings/enums/slideshow_video_playback.dart index beda9a052..453ddf29b 100644 --- a/lib/model/settings/enums/slideshow_video_playback.dart +++ b/lib/model/settings/enums/slideshow_video_playback.dart @@ -7,11 +7,11 @@ extension ExtraSlideshowVideoPlayback on SlideshowVideoPlayback { String getName(BuildContext context) { switch (this) { case SlideshowVideoPlayback.skip: - return context.l10n.slideshowVideoPlaybackSkip; + return context.l10n.videoPlaybackSkip; case SlideshowVideoPlayback.playMuted: - return context.l10n.slideshowVideoPlaybackMuted; + return context.l10n.videoPlaybackMuted; case SlideshowVideoPlayback.playWithSound: - return context.l10n.slideshowVideoPlaybackWithSound; + return context.l10n.videoPlaybackWithSound; } } } diff --git a/lib/model/settings/enums/video_auto_play_mode.dart b/lib/model/settings/enums/video_auto_play_mode.dart new file mode 100644 index 000000000..9552cedcb --- /dev/null +++ b/lib/model/settings/enums/video_auto_play_mode.dart @@ -0,0 +1,17 @@ +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:flutter/widgets.dart'; + +import 'enums.dart'; + +extension ExtraSlideshowVideoPlayback on VideoAutoPlayMode { + String getName(BuildContext context) { + switch (this) { + case VideoAutoPlayMode.disabled: + return context.l10n.settingsDisabled; + case VideoAutoPlayMode.playMuted: + return context.l10n.videoPlaybackMuted; + case VideoAutoPlayMode.playWithSound: + return context.l10n.videoPlaybackWithSound; + } + } +} diff --git a/lib/model/settings/settings.dart b/lib/model/settings/settings.dart index e5f8c873a..6cd843e1a 100644 --- a/lib/model/settings/settings.dart +++ b/lib/model/settings/settings.dart @@ -112,7 +112,7 @@ class Settings extends ChangeNotifier { // video static const enableVideoHardwareAccelerationKey = 'video_hwaccel_mediacodec'; - static const enableVideoAutoPlayKey = 'video_auto_play'; + static const videoAutoPlayModeKey = 'video_auto_play_mode'; static const videoLoopModeKey = 'video_loop'; static const videoShowRawTimedTextKey = 'video_show_raw_timed_text'; static const videoControlsKey = 'video_controls'; @@ -534,9 +534,9 @@ class Settings extends ChangeNotifier { set enableVideoHardwareAcceleration(bool newValue) => setAndNotify(enableVideoHardwareAccelerationKey, newValue); - bool get enableVideoAutoPlay => getBoolOrDefault(enableVideoAutoPlayKey, SettingsDefaults.enableVideoAutoPlay); + VideoAutoPlayMode get videoAutoPlayMode => getEnumOrDefault(videoAutoPlayModeKey, SettingsDefaults.videoAutoPlayMode, VideoAutoPlayMode.values); - set enableVideoAutoPlay(bool newValue) => setAndNotify(enableVideoAutoPlayKey, newValue); + set videoAutoPlayMode(VideoAutoPlayMode newValue) => setAndNotify(videoAutoPlayModeKey, newValue.toString()); VideoLoopMode get videoLoopMode => getEnumOrDefault(videoLoopModeKey, SettingsDefaults.videoLoopMode, VideoLoopMode.values); @@ -874,7 +874,6 @@ class Settings extends ChangeNotifier { case viewerMaxBrightnessKey: case enableMotionPhotoAutoPlayKey: case enableVideoHardwareAccelerationKey: - case enableVideoAutoPlayKey: case videoGestureDoubleTapTogglePlayKey: case videoGestureSideDoubleTapSeekKey: case subtitleShowOutlineKey: @@ -903,6 +902,7 @@ class Settings extends ChangeNotifier { case countrySortFactorKey: case tagSortFactorKey: case imageBackgroundKey: + case videoAutoPlayModeKey: case videoLoopModeKey: case videoControlsKey: case subtitleTextAlignmentKey: diff --git a/lib/widgets/settings/video/video.dart b/lib/widgets/settings/video/video.dart index d1711ac51..1264c82c3 100644 --- a/lib/widgets/settings/video/video.dart +++ b/lib/widgets/settings/video/video.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:aves/model/filters/mime.dart'; import 'package:aves/model/settings/enums/enums.dart'; +import 'package:aves/model/settings/enums/video_auto_play_mode.dart'; import 'package:aves/model/settings/enums/video_loop_mode.dart'; import 'package:aves/model/settings/settings.dart'; import 'package:aves/theme/colors.dart'; @@ -73,13 +74,15 @@ class SettingsTileVideoEnableHardwareAcceleration extends SettingsTile { class SettingsTileVideoEnableAutoPlay extends SettingsTile { @override - String title(BuildContext context) => context.l10n.settingsVideoEnableAutoPlay; + String title(BuildContext context) => context.l10n.settingsVideoAutoPlay; @override - Widget build(BuildContext context) => SettingsSwitchListTile( - selector: (context, s) => s.enableVideoAutoPlay, - onChanged: (v) => settings.enableVideoAutoPlay = v, - title: title(context), + Widget build(BuildContext context) => SettingsSelectionListTile( + values: VideoAutoPlayMode.values, + getName: (context, v) => v.getName(context), + selector: (context, s) => s.videoAutoPlayMode, + onSelection: (v) => settings.videoAutoPlayMode = v, + tileTitle: title(context), ); } diff --git a/lib/widgets/viewer/visual/controller_mixin.dart b/lib/widgets/viewer/visual/controller_mixin.dart index b00031a61..cc64293f8 100644 --- a/lib/widgets/viewer/visual/controller_mixin.dart +++ b/lib/widgets/viewer/visual/controller_mixin.dart @@ -66,7 +66,7 @@ mixin EntryViewControllerMixin on State { } } - bool _shouldAutoPlayVideo(BuildContext context) { + bool get videoAutoPlayEnabled { if (!isViewingImage) return false; switch (videoPlaybackOverride) { @@ -76,11 +76,39 @@ mixin EntryViewControllerMixin on State { case SlideshowVideoPlayback.playWithSound: return true; case null: - return settings.enableVideoAutoPlay; + break; + } + + switch (settings.videoAutoPlayMode) { + case VideoAutoPlayMode.disabled: + return false; + case VideoAutoPlayMode.playMuted: + case VideoAutoPlayMode.playWithSound: + return true; } } - bool _shouldAutoPlayMotionPhoto(BuildContext context) { + bool get shouldAutoPlayVideoMuted { + switch (videoPlaybackOverride) { + case SlideshowVideoPlayback.skip: + case SlideshowVideoPlayback.playWithSound: + return false; + case SlideshowVideoPlayback.playMuted: + return true; + case null: + break; + } + + switch (settings.videoAutoPlayMode) { + case VideoAutoPlayMode.disabled: + case VideoAutoPlayMode.playWithSound: + return false; + case VideoAutoPlayMode.playMuted: + return true; + } + } + + bool get shouldAutoPlayMotionPhoto { if (!isViewingImage) return false; return settings.enableMotionPhotoAutoPlay; @@ -90,7 +118,7 @@ mixin EntryViewControllerMixin on State { final controller = context.read().getOrCreateController(entry); setState(() {}); - if (_shouldAutoPlayVideo(context)) { + if (videoAutoPlayEnabled) { final resumeTimeMillis = await controller.getResumeTime(context); await _playVideo(controller, () => entry == entryNotifier.value, resumeTimeMillis: resumeTimeMillis); } @@ -117,7 +145,7 @@ mixin EntryViewControllerMixin on State { // auto play/pause when changing page Future _onPageChange() async { await pauseVideoControllers(); - if (_shouldAutoPlayVideo(context) || (entry.isMotionPhoto && _shouldAutoPlayMotionPhoto(context))) { + if (videoAutoPlayEnabled || (entry.isMotionPhoto && shouldAutoPlayMotionPhoto)) { final page = multiPageController.page; final pageInfo = multiPageInfo.getByIndex(page)!; if (pageInfo.isVideo) { @@ -135,7 +163,7 @@ mixin EntryViewControllerMixin on State { multiPageController.pageNotifier.addListener(_onPageChange); await _onPageChange(); - if (entry.isMotionPhoto && _shouldAutoPlayMotionPhoto(context)) { + if (entry.isMotionPhoto && shouldAutoPlayMotionPhoto) { await Future.delayed(Durations.motionPhotoAutoPlayDelay); if (entry == entryNotifier.value) { multiPageController.page = 1; @@ -160,7 +188,7 @@ mixin EntryViewControllerMixin on State { // so we play after a delay for increased stability await Future.delayed(const Duration(milliseconds: 300) * timeDilation); - if (videoPlaybackOverride == SlideshowVideoPlayback.playMuted && !videoController.isMuted) { + if (!videoController.isMuted && shouldAutoPlayVideoMuted) { await videoController.toggleMute(); } diff --git a/untranslated.json b/untranslated.json index 23acffbc6..9586fe36b 100644 --- a/untranslated.json +++ b/untranslated.json @@ -8,6 +8,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", + "settingsDisabled", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", "wallpaperUseScrollEffect" @@ -22,6 +23,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", + "settingsDisabled", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", "wallpaperUseScrollEffect" @@ -50,6 +52,7 @@ "albumGroupType", "albumMimeTypeMixed", "searchMetadataSectionTitle", + "settingsDisabled", "settingsConfirmationAfterMoveToBinItems", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", @@ -57,6 +60,10 @@ "wallpaperUseScrollEffect" ], + "fr": [ + "settingsDisabled" + ], + "id": [ "chipActionFilterOut", "chipActionFilterIn", @@ -66,6 +73,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", + "settingsDisabled", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", "wallpaperUseScrollEffect" @@ -80,6 +88,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", + "settingsDisabled", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", "wallpaperUseScrollEffect" @@ -108,6 +117,7 @@ "albumGroupType", "albumMimeTypeMixed", "searchMetadataSectionTitle", + "settingsDisabled", "settingsConfirmationAfterMoveToBinItems", "settingsViewerGestureSideTapNext", "settingsWidgetOpenPage", @@ -116,6 +126,10 @@ "wallpaperUseScrollEffect" ], + "ko": [ + "settingsDisabled" + ], + "nl": [ "chipActionFilterOut", "chipActionFilterIn", @@ -125,6 +139,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", + "settingsDisabled", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", "wallpaperUseScrollEffect" @@ -139,6 +154,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", + "settingsDisabled", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", "wallpaperUseScrollEffect" @@ -153,6 +169,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", + "settingsDisabled", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", "wallpaperUseScrollEffect" @@ -168,9 +185,9 @@ "filterNoTitleLabel", "filterOnThisDayLabel", "filterRecentlyAddedLabel", - "slideshowVideoPlaybackSkip", - "slideshowVideoPlaybackMuted", - "slideshowVideoPlaybackWithSound", + "videoPlaybackSkip", + "videoPlaybackMuted", + "videoPlaybackWithSound", "viewerTransitionSlide", "viewerTransitionParallax", "viewerTransitionFade", @@ -195,6 +212,7 @@ "albumGroupType", "albumMimeTypeMixed", "searchMetadataSectionTitle", + "settingsDisabled", "settingsConfirmationAfterMoveToBinItems", "settingsViewerGestureSideTapNext", "settingsViewerSlideshowTile", @@ -226,6 +244,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", + "settingsDisabled", "settingsWidgetOpenPage", "statsTopAlbumsSectionTitle", "wallpaperUseScrollEffect"