Skip to content

Commit

Permalink
feat(mobile): add ability to force view original videos (#15094)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidijusr authored Jan 6, 2025
1 parent 1f0ffd6 commit a13b7b3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
4 changes: 3 additions & 1 deletion mobile/assets/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@
"settings_require_restart": "Please restart Immich to apply this setting",
"setting_video_viewer_looping_subtitle": "Enable to automatically loop a video in the detail viewer.",
"setting_video_viewer_looping_title": "Looping",
"setting_video_viewer_original_video_title": "Force original video",
"setting_video_viewer_original_video_subtitle": "When streaming a video from the server, play the original even when a transcode is available. May lead to buffering. Videos available locally are played in original quality regardless of this setting.",
"setting_video_viewer_title": "Videos",
"share_add": "Add",
"share_add_photos": "Add photos",
Expand Down Expand Up @@ -656,4 +658,4 @@
"viewer_unstack": "Un-Stack",
"wifi_name": "WiFi Name",
"your_wifi_name": "Your WiFi name"
}
}
3 changes: 3 additions & 0 deletions mobile/lib/entities/store.entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ enum StoreKey<T> {
preferredWifiName<String>(133, type: String),
localEndpoint<String>(134, type: String),
externalEndpointList<String>(135, type: String),

// Video settings
loadOriginalVideo<bool>(136, type: bool),
;

const StoreKey(
Expand Down
9 changes: 7 additions & 2 deletions mobile/lib/pages/common/native_video_viewer.page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ class NativeVideoViewerPage extends HookConsumerWidget {

// Use a network URL for the video player controller
final serverEndpoint = Store.get(StoreKey.serverEndpoint);
final isOriginalVideo = ref
.read(appSettingsServiceProvider)
.getSetting<bool>(AppSettingsEnum.loadOriginalVideo);
final String postfixUrl =
isOriginalVideo ? 'original' : 'video/playback';
final String videoUrl = asset.livePhotoVideoId != null
? '$serverEndpoint/assets/${asset.livePhotoVideoId}/video/playback'
: '$serverEndpoint/assets/${asset.remoteId}/video/playback';
? '$serverEndpoint/assets/${asset.livePhotoVideoId}/$postfixUrl'
: '$serverEndpoint/assets/${asset.remoteId}/$postfixUrl';

final source = await VideoSource.init(
path: videoUrl,
Expand Down
5 changes: 5 additions & 0 deletions mobile/lib/services/app_settings.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ enum AppSettingsEnum<T> {
logLevel<int>(StoreKey.logLevel, null, 5), // Level.INFO = 5
preferRemoteImage<bool>(StoreKey.preferRemoteImage, null, false),
loopVideo<bool>(StoreKey.loopVideo, "loopVideo", true),
loadOriginalVideo<bool>(
StoreKey.loadOriginalVideo,
"loadOriginalVideo",
false,
),
mapThemeMode<int>(StoreKey.mapThemeMode, null, 0),
mapShowFavoriteOnly<bool>(StoreKey.mapShowFavoriteOnly, null, false),
mapIncludeArchived<bool>(StoreKey.mapIncludeArchived, null, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class VideoViewerSettings extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final useLoopVideo = useAppSettingsState(AppSettingsEnum.loopVideo);
final useOriginalVideo =
useAppSettingsState(AppSettingsEnum.loadOriginalVideo);

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand All @@ -26,6 +28,12 @@ class VideoViewerSettings extends HookConsumerWidget {
subtitle: "setting_video_viewer_looping_subtitle".tr(),
onChanged: (_) => ref.invalidate(appSettingsServiceProvider),
),
SettingsSwitchListTile(
valueNotifier: useOriginalVideo,
title: "setting_video_viewer_original_video_title".tr(),
subtitle: "setting_video_viewer_original_video_subtitle".tr(),
onChanged: (_) => ref.invalidate(appSettingsServiceProvider),
),
],
);
}
Expand Down

0 comments on commit a13b7b3

Please sign in to comment.