Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@
"videoCodecsDescription": "Unchecked codecs are transcoded by the server",
"videoCodecsAlwaysAccepted": "Always accepted",
"musicQualityTitle": "Music Quality",
"forceSubtitles": "Always Show Subtitles",
"forceSubtitlesDescription": "Turn subtitles on even when the server selects none",
"preferredSubtitleLanguage": "Preferred Subtitle Language",
"preferredSubtitleLanguageNotSet": "Not set",
"autoDownloadSubtitles": "Auto-Download Subtitles",
"autoDownloadSubtitlesDescription": "Fetch a subtitle from your Plex server's providers when the item has none in your language",
"subtitleStyling": "Subtitle Styling",
"subtitleStylingDescription": "Customize subtitle appearance",
"smallSkipDuration": "Small Skip Duration",
Expand Down Expand Up @@ -893,6 +899,7 @@
"noAudioDevicesAvailable": "No audio devices available",
"searchSubtitles": "Search Subtitles",
"language": "Language",
"fetchingSubtitles": "Fetching subtitles…",
"noSubtitlesFound": "No subtitles found",
"subtitleDownloaded": "Subtitle downloaded",
"subtitleDownloadedNotApplied": "Subtitle downloaded, but it could not be selected",
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/strings.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// To regenerate, run: `dart run slang`
///
/// Locales: 22
/// Strings: 50956 (2316 per locale)
/// Strings: 50963 (2316 per locale)

// coverage:ignore-file
// ignore_for_file: type=lint, unused_import
Expand Down
44 changes: 36 additions & 8 deletions lib/i18n/strings_en.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,24 @@ class Translations$settings$en {
/// en: 'Music Quality'
String get musicQualityTitle => 'Music Quality';

/// en: 'Always Show Subtitles'
String get forceSubtitles => 'Always Show Subtitles';

/// en: 'Turn subtitles on even when the server selects none'
String get forceSubtitlesDescription => 'Turn subtitles on even when the server selects none';

/// en: 'Preferred Subtitle Language'
String get preferredSubtitleLanguage => 'Preferred Subtitle Language';

/// en: 'Not set'
String get preferredSubtitleLanguageNotSet => 'Not set';

/// en: 'Auto-Download Subtitles'
String get autoDownloadSubtitles => 'Auto-Download Subtitles';

/// en: 'Fetch a subtitle from your Plex server's providers when the item has none in your language'
String get autoDownloadSubtitlesDescription => 'Fetch a subtitle from your Plex server\'s providers when the item has none in your language';

/// en: 'Subtitle Styling'
String get subtitleStyling => 'Subtitle Styling';

Expand Down Expand Up @@ -2485,6 +2503,9 @@ class Translations$videoControls$en {
/// en: 'Language'
String get language => 'Language';

/// en: 'Fetching subtitles…'
String get fetchingSubtitles => 'Fetching subtitles…';

/// en: 'No subtitles found'
String get noSubtitlesFound => 'No subtitles found';

Expand Down Expand Up @@ -8372,6 +8393,12 @@ extension on Translations {
'settings.videoCodecsDescription' => 'Unchecked codecs are transcoded by the server',
'settings.videoCodecsAlwaysAccepted' => 'Always accepted',
'settings.musicQualityTitle' => 'Music Quality',
'settings.forceSubtitles' => 'Always Show Subtitles',
'settings.forceSubtitlesDescription' => 'Turn subtitles on even when the server selects none',
'settings.preferredSubtitleLanguage' => 'Preferred Subtitle Language',
'settings.preferredSubtitleLanguageNotSet' => 'Not set',
'settings.autoDownloadSubtitles' => 'Auto-Download Subtitles',
'settings.autoDownloadSubtitlesDescription' => 'Fetch a subtitle from your Plex server\'s providers when the item has none in your language',
'settings.subtitleStyling' => 'Subtitle Styling',
'settings.subtitleStylingDescription' => 'Customize subtitle appearance',
'settings.smallSkipDuration' => 'Small Skip Duration',
Expand Down Expand Up @@ -8625,14 +8652,14 @@ extension on Translations {
'themeEditor.startFrom' => 'Start from',
'themeEditor.startFromDescription' => 'Copy all colors from another theme',
'themeEditor.colors' => 'Colors',
_ => null,
} ?? switch (path) {
'themeEditor.preview' => 'Preview',
'themeEditor.slots.bg' => 'Background',
'themeEditor.slots.surface' => 'Surface',
'themeEditor.slots.outline' => 'Outline',
'themeEditor.slots.text' => 'Text',
'themeEditor.slots.textMuted' => 'Secondary text',
_ => null,
} ?? switch (path) {
'themeEditor.slots.accent' => 'Accent',
'themeEditor.opacity' => 'Opacity',
'themeEditor.hexHint' => '#RRGGBB or #AARRGGBB',
Expand Down Expand Up @@ -8955,6 +8982,7 @@ extension on Translations {
'videoControls.noAudioDevicesAvailable' => 'No audio devices available',
'videoControls.searchSubtitles' => 'Search Subtitles',
'videoControls.language' => 'Language',
'videoControls.fetchingSubtitles' => 'Fetching subtitles…',
'videoControls.noSubtitlesFound' => 'No subtitles found',
'videoControls.subtitleDownloaded' => 'Subtitle downloaded',
'videoControls.subtitleDownloadedNotApplied' => 'Subtitle downloaded, but it could not be selected',
Expand Down Expand Up @@ -9138,15 +9166,15 @@ extension on Translations {
'profiles.incorrectPin' => 'Incorrect PIN.',
'profiles.incorrectPinTryAgain' => 'Incorrect PIN. Please try again.',
'profiles.sourceProfileMissingParentAccount' => 'Source profile is missing its parent account.',
_ => null,
} ?? switch (path) {
'profiles.failedToLoadHomeUsers' => 'Could not load your Plex Home users. Check your connection and try again.',
'profiles.failedToVerifyPin' => 'Failed to verify PIN.',
'profiles.newProfile' => 'New profile',
'profiles.profileNameHint' => 'e.g. Guests, Kids, Family Room',
'profiles.pinProtectionOptional' => 'PIN protection (optional)',
'profiles.pinExplain' => '4-digit PIN required to switch profiles.',
'profiles.continueButton' => 'Continue',
_ => null,
} ?? switch (path) {
'profiles.pinsDontMatch' => 'PINs don\'t match',
'profiles.tokenIdentityMismatch' => 'The Plex profile token resolved to an unexpected server',
'connections.sectionTitle' => 'Connections',
Expand Down Expand Up @@ -9652,15 +9680,15 @@ extension on Translations {
'liveTv.processRecordingRules' => 'Re-evaluate rules',
'liveTv.recordingInProgress' => 'Recording now',
'liveTv.recordingsCount' => ({required Object count}) => '${count} scheduled',
_ => null,
} ?? switch (path) {
'liveTv.editRule' => 'Edit rule',
'liveTv.editRuleAction' => 'Edit',
'liveTv.recordingRuleUpdated' => 'Recording rule updated',
'liveTv.guideReloadRequested' => 'Guide refresh requested',
'liveTv.guideReloadFailed' => 'Couldn\'t refresh the guide',
'liveTv.rulesProcessRequested' => 'Rule re-evaluation requested',
'liveTv.rulesProcessFailed' => 'Couldn\'t re-evaluate recording rules',
_ => null,
} ?? switch (path) {
'liveTv.recordShow' => 'Record show',
'liveTv.recordSettings.startEarly' => 'Start early (seconds)',
'liveTv.recordSettings.endLate' => 'End late (seconds)',
Expand Down Expand Up @@ -10166,15 +10194,15 @@ extension on Translations {
'performanceOverlay.dvSampleAverage' => 'DV Sample Avg',
'performanceOverlay.maxLuma' => 'Max Luma',
'performanceOverlay.minLuma' => 'Min Luma',
_ => null,
} ?? switch (path) {
'performanceOverlay.maxCll' => 'MaxCLL',
'performanceOverlay.maxFall' => 'MaxFALL',
'performanceOverlay.cacheUsed' => 'Cache Used',
'performanceOverlay.cacheLimit' => 'Cache Limit',
'performanceOverlay.speed' => 'Speed',
'performanceOverlay.player' => 'Player',
'performanceOverlay.playMethod' => 'Play Method',
_ => null,
} ?? switch (path) {
'performanceOverlay.memory' => 'Memory',
'performanceOverlay.uiFps' => 'UI FPS',
'performanceOverlay.fps' => 'FPS',
Expand Down
26 changes: 26 additions & 0 deletions lib/screens/settings/playback_settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '../../utils/quality_preset_labels.dart';
import '../../services/settings_service.dart';
import '../../services/video_decode_capabilities.dart';
import '../../utils/codec_utils.dart';
import '../../utils/language_codes.dart';
import '../../utils/platform_detector.dart';
import '../../widgets/setting_tile.dart';
import '../../widgets/settings_builder.dart';
Expand Down Expand Up @@ -134,6 +135,31 @@ class PlaybackSettingsScreen extends StatelessWidget {
SettingsGroup(
title: t.settings.subtitles,
children: [
SettingSwitchTile(
pref: SettingsService.forceSubtitles,
icon: Symbols.closed_caption_rounded,
title: t.settings.forceSubtitles,
subtitle: t.settings.forceSubtitlesDescription,
),
SettingSelectionTile<String?>(
pref: SettingsService.subtitleSearchLanguage,
icon: Symbols.language_rounded,
title: t.settings.preferredSubtitleLanguage,
subtitleBuilder: (code) => code == null
? t.settings.preferredSubtitleLanguageNotSet
: LanguageCodes.getLanguageName(code) ?? code,
options: [
DialogOption(value: null, title: t.settings.preferredSubtitleLanguageNotSet),
for (final language in LanguageCodes.getAllLanguages())
DialogOption(value: language.code, title: language.name),
],
),
SettingSwitchTile(
pref: SettingsService.autoDownloadSubtitles,
icon: Symbols.cloud_download_rounded,
title: t.settings.autoDownloadSubtitles,
subtitle: t.settings.autoDownloadSubtitlesDescription,
),
SettingNavigationTile(
icon: Symbols.subtitles_rounded,
title: t.settings.subtitleStyling,
Expand Down
9 changes: 8 additions & 1 deletion lib/screens/video_player/parts/episode_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ extension _VideoPlayerEpisodeNavigationMethods on VideoPlayerScreenState {
}
final followServerSelections = settingsService.read(SettingsService.followServerTrackSelections);
final committedSubtitleSelection = _playbackSession?.subtitleSelection;
final primarySubtitlePreference = followServerSelections
// A pick the always-on fallback supplied is not a choice, so it must not
// be carried: a carried selection matches at navigation priority on the
// next episode, which persists it to the server as if the viewer had
// chosen it. The live native track is that same pick, so it cannot stand
// in either - the next episode starts from no preference and runs the
// fallback for itself.
final subtitleCameFromFallback = committedSubtitleSelection?.isForcedFallback == true;
final primarySubtitlePreference = followServerSelections || subtitleCameFromFallback
? null
: subtitlePreferenceForItemChange(
hasCommittedSelection: committedSubtitleSelection != null,
Expand Down
5 changes: 5 additions & 0 deletions lib/screens/video_player/parts/playback_open.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ extension _VideoPlayerOpenMethods on VideoPlayerScreenState {
await _waitForProfileSettingsIfNeeded();
if (!mounted) return const PlaybackSubtitleSelection.off();

final settings = await SettingsService.getInstance();
if (!mounted) return const PlaybackSubtitleSelection.off();

return PlaybackSubtitleResolver.resolve(
metadata: metadata,
mediaInfo: result.mediaInfo,
Expand All @@ -130,6 +133,8 @@ extension _VideoPlayerOpenMethods on VideoPlayerScreenState {
preferredSecondarySubtitleTrack: preferredSecondarySubtitleTrack,
preserveSourceIdentity: preserveSubtitleSourceIdentity,
isTranscoding: result.isTranscoding,
forceSubtitles: settings.read(SettingsService.forceSubtitles),
forcedSubtitleLanguage: resolveSubtitleLanguageFromSettings(settings),
);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/screens/video_player_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../services/subtitle_language.dart';
import 'package:plezy/widgets/app_icon.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:flutter/services.dart';
Expand Down
15 changes: 14 additions & 1 deletion lib/services/playback_subtitle_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class PlaybackSubtitleSelection {
final PlaybackSubtitleSidecar? secondarySidecar;
final List<PlaybackSubtitleSidecar> preloadedSidecars;

/// The primary track came from the always-on fallback rather than from the
/// viewer or the server, so it must not cross an item boundary: a carried
/// selection matches at navigation priority on the next item and is
/// persisted to the server as an explicit choice. Each item derives its own.
final bool isForcedFallback;

/// The primary preference the resolver could not serve when this selection
/// is off. Distinguishes "the carried choice declined and the ladder fell
/// through" from a deliberate off (#1785): the open flow hands the declined
Expand All @@ -70,13 +76,15 @@ class PlaybackSubtitleSelection {
this.preloadedSidecars = const [],
this.declinedPreference,
this.primaryHonorsPreference = false,
this.isForcedFallback = false,
});

const PlaybackSubtitleSelection.off({
this.preloadedSidecars = const [],
this.declinedPreference,
this.primaryHonorsPreference = false,
}) : primaryTrack = SubtitleTrack.off,
}) : isForcedFallback = false,
primaryTrack = SubtitleTrack.off,
primarySourceStreamId = null,
primarySidecar = null,
secondaryTrack = null,
Expand Down Expand Up @@ -172,6 +180,8 @@ class PlaybackSubtitleResolver {
SubtitlePreference? preferredSecondarySubtitleTrack,
bool preserveSourceIdentity = true,
bool isTranscoding = false,
bool forceSubtitles = false,
String? forcedSubtitleLanguage,
}) {
final candidates = <_SubtitleCandidate>[];
final matchedSidecars = <PlaybackSubtitleSidecar>{};
Expand Down Expand Up @@ -203,6 +213,8 @@ class PlaybackSubtitleResolver {
profileSettings: profileSettings,
metadata: metadata,
plexMediaInfo: mediaInfo,
forceSubtitles: forceSubtitles,
forcedSubtitleLanguage: forcedSubtitleLanguage,
);
final selectedAudio = service.selectAudioTrack(audioTracksForSource(mediaInfo), preferredAudioTrack)?.track;
final primaryPreference = _sourceBackedPreference(
Expand Down Expand Up @@ -270,6 +282,7 @@ class PlaybackSubtitleResolver {
secondarySidecar: secondaryCandidate?.sidecar,
preloadedSidecars: preloadedSidecars,
primaryHonorsPreference: primaryHonorsPreference,
isForcedFallback: primaryResult?.forcedFallback ?? false,
);
}

Expand Down
15 changes: 15 additions & 0 deletions lib/services/settings_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,20 @@ class SettingsService extends BaseSharedPreferencesService {
static const sleepTimerDuration = IntPref('sleep_timer_duration', defaultValue: 30);
static const audioSyncOffset = IntPref('audio_sync_offset');
static const subtitleSyncOffset = IntPref('subtitle_sync_offset');

/// Preferred subtitle language, shared by the search sheet, the always-on
/// fallback ([forceSubtitles]) and [autoDownloadSubtitles]. One language,
/// one key: a second "preferred language" pref could disagree with this one.
static const subtitleSearchLanguage = NullableStringPref('subtitle_search_language');

/// Keep subtitles on even when neither the server nor a carried preference
/// selects one. An explicit in-session "off" still wins.
static const forceSubtitles = BoolPref('force_subtitles');

/// Fetch a subtitle from the server's online providers when the item carries
/// nothing in [subtitleSearchLanguage]. Plex only.
static const autoDownloadSubtitles = BoolPref('auto_download_subtitles');

static const volume = DoublePref('volume', defaultValue: 100.0);
static const rotationLocked = BoolPref('rotation_locked', defaultValue: true);
static const subtitleFontSize = IntPref('subtitle_font_size', defaultValue: 38);
Expand Down Expand Up @@ -1498,6 +1511,8 @@ class SettingsService extends BaseSharedPreferencesService {
audioSyncOffset,
subtitleSyncOffset,
subtitleSearchLanguage,
forceSubtitles,
autoDownloadSubtitles,
volume,
subtitleFontSize,
subtitleTextColor,
Expand Down
Loading