A cross platform Audiobookshelf client for Android and iOS
Dart
Add a setting to fix seeking in variable bitrate MP3s
Barnabas68e3e41d1b20
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arbindex ddf17acc..a43fa7e5 100644--- a/lib/l10n/app_en.arb+++ b/lib/l10n/app_en.arb@@ -952,6 +952,11 @@"closeApp": "Close App","trustAllCertificates": "Trust all certificates","trustAllCertificatesInfoTitle": "Self-signed Certificates",+ "mp3IndexSeeking": "MP3 index seeking",+ "mp3IndexSeekingInfoTitle": "MP3 Index Seeking",+ "mp3IndexSeekingInfoContent": "Only enable this if you have MP3 files that don't seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.",+ "mp3IndexSeekingOnSubtitle": "On - exact seeking for VBR MP3 files",+ "mp3IndexSeekingOffSubtitle": "Off - normal seeking","trustAllCertificatesInfoContent": "Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.","trustAllCertificatesOnSubtitle": "On - accepting all certificates","trustAllCertificatesOffSubtitle": "Off - only trusted certificates accepted",diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dartindex a7774a47..121aff85 100644--- a/lib/l10n/app_localizations.dart+++ b/lib/l10n/app_localizations.dart@@ -3706,6 +3706,36 @@ abstract class AppLocalizations {/// **'Self-signed Certificates'**String get trustAllCertificatesInfoTitle;+ /// No description provided for @mp3IndexSeeking.+ ///+ /// In en, this message translates to:+ /// **'MP3 index seeking'**+ String get mp3IndexSeeking;++ /// No description provided for @mp3IndexSeekingInfoTitle.+ ///+ /// In en, this message translates to:+ /// **'MP3 Index Seeking'**+ String get mp3IndexSeekingInfoTitle;++ /// No description provided for @mp3IndexSeekingInfoContent.+ ///+ /// In en, this message translates to:+ /// **'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.'**+ String get mp3IndexSeekingInfoContent;++ /// No description provided for @mp3IndexSeekingOnSubtitle.+ ///+ /// In en, this message translates to:+ /// **'On - exact seeking for VBR MP3 files'**+ String get mp3IndexSeekingOnSubtitle;++ /// No description provided for @mp3IndexSeekingOffSubtitle.+ ///+ /// In en, this message translates to:+ /// **'Off - normal seeking'**+ String get mp3IndexSeekingOffSubtitle;+/// No description provided for @trustAllCertificatesInfoContent.////// In en, this message translates to:diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dartindex 87470243..358c8a61 100644--- a/lib/l10n/app_localizations_de.dart+++ b/lib/l10n/app_localizations_de.dart@@ -2021,6 +2021,23 @@ class AppLocalizationsDe extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Selbstsignierte Zertifikate';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Aktiviere dies, wenn dein Audiobookshelf-Server ein selbstsigniertes Zertifikat oder eine eigene Root-CA verwendet. Wenn aktiviert, überspringt Absorb die TLS-Zertifikatsprüfung für alle Verbindungen. Aktiviere dies nur, wenn du deinem Netzwerk vertraust.';diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dartindex 4069ff39..ca877999 100644--- a/lib/l10n/app_localizations_el.dart+++ b/lib/l10n/app_localizations_el.dart@@ -1999,6 +1999,23 @@ class AppLocalizationsEl extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dartindex 5a0d5746..015931a3 100644--- a/lib/l10n/app_localizations_en.dart+++ b/lib/l10n/app_localizations_en.dart@@ -1999,6 +1999,23 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dartindex 20e625fd..16656879 100644--- a/lib/l10n/app_localizations_es.dart+++ b/lib/l10n/app_localizations_es.dart@@ -2001,6 +2001,23 @@ class AppLocalizationsEs extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dartindex 10ffb73c..dd756f99 100644--- a/lib/l10n/app_localizations_fr.dart+++ b/lib/l10n/app_localizations_fr.dart@@ -2017,6 +2017,23 @@ class AppLocalizationsFr extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dartindex 9ace3bfc..f0651af7 100644--- a/lib/l10n/app_localizations_it.dart+++ b/lib/l10n/app_localizations_it.dart@@ -1999,6 +1999,23 @@ class AppLocalizationsIt extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dartindex 5e8ad435..cc2b1920 100644--- a/lib/l10n/app_localizations_ja.dart+++ b/lib/l10n/app_localizations_ja.dart@@ -1999,6 +1999,23 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dartindex 9ba4b508..280bcc57 100644--- a/lib/l10n/app_localizations_no.dart+++ b/lib/l10n/app_localizations_no.dart@@ -1999,6 +1999,23 @@ class AppLocalizationsNo extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dartindex 40048470..af50d403 100644--- a/lib/l10n/app_localizations_pt.dart+++ b/lib/l10n/app_localizations_pt.dart@@ -1999,6 +1999,23 @@ class AppLocalizationsPt extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dartindex 6a265293..20638d60 100644--- a/lib/l10n/app_localizations_ro.dart+++ b/lib/l10n/app_localizations_ro.dart@@ -1999,6 +1999,23 @@ class AppLocalizationsRo extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dartindex 0864400b..b79c3812 100644--- a/lib/l10n/app_localizations_ru.dart+++ b/lib/l10n/app_localizations_ru.dart@@ -2003,6 +2003,23 @@ class AppLocalizationsRu extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => 'Self-signed Certificates';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.';diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dartindex 56fa7323..ed30fd3a 100644--- a/lib/l10n/app_localizations_zh.dart+++ b/lib/l10n/app_localizations_zh.dart@@ -1950,6 +1950,23 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get trustAllCertificatesInfoTitle => '自签名证书';+ @override+ String get mp3IndexSeeking => 'MP3 index seeking';++ @override+ String get mp3IndexSeekingInfoTitle => 'MP3 Index Seeking';++ @override+ String get mp3IndexSeekingInfoContent =>+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';++ @override+ String get mp3IndexSeekingOnSubtitle =>+ 'On - exact seeking for VBR MP3 files';++ @override+ String get mp3IndexSeekingOffSubtitle => 'Off - normal seeking';+@overrideString get trustAllCertificatesInfoContent =>'如果你的 Audiobookshelf 服务器使用自签名证书或自定义根 CA,请启用此选项。启用后,Absorb 将跳过所有连接的 TLS 证书验证。仅在您信任当前网络环境时启用。';diff --git a/lib/main.dart b/lib/main.dartindex 164eef64..04c0f525 100644--- a/lib/main.dart+++ b/lib/main.dart@@ -195,6 +195,7 @@ void main() async {snappyTransitionsNotifier.value = await PlayerSettings.getSnappyTransitions();classicWordingNotifier.value = await PlayerSettings.getClassicWording();PlayerSettings.showExplicitBadge = await PlayerSettings.getShowExplicitBadge();+ PlayerSettings.mp3IndexSeeking = await PlayerSettings.getMp3IndexSeeking();// Restore last cover seed color so the theme doesn't flash on startup{final seedInt = await PlayerSettings.getCoverSeedColor();@@ -608,6 +609,7 @@ class _AuthGateState extends State<AuthGate> {snappyTransitionsNotifier.value = await PlayerSettings.getSnappyTransitions();classicWordingNotifier.value = await PlayerSettings.getClassicWording();PlayerSettings.showExplicitBadge = await PlayerSettings.getShowExplicitBadge();+ PlayerSettings.mp3IndexSeeking = await PlayerSettings.getMp3IndexSeeking();// Rotation lock: main() applied it before scope was active, so that pass// read the never-written unscoped key and always came up unlocked. The// timeout matters: on a headless boot (Android Auto bind) there is nodiff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex eed3ea1c..632715ea 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -74,6 +74,7 @@ class _SettingsScreenState extends State<SettingsScreen> {bool _notifChapterProgress = false;bool _notifSpeedBookmark = false;bool _lockSeekBar = false;+ bool _mp3IndexSeeking = false;bool _speedAdjustedTime = true;int _forwardSkip = 30;int _backSkip = 10;@@ -753,6 +754,7 @@ class _SettingsScreenState extends State<SettingsScreen> {]);final s = results[0] as AutoRewindSettings;final progressScale = results.last as double;+ final mp3IndexSeek = await PlayerSettings.getMp3IndexSeeking();final flatBackground = await PlayerSettings.getFlatBackground();final colorSource = await PlayerSettings.getColorSource();final manualSeed = await PlayerSettings.getManualSeedColor();@@ -865,6 +867,7 @@ class _SettingsScreenState extends State<SettingsScreen> {_fullScreenPlayer = fullScreen;_snappyTransitions = snappyTrans;_classicWording = classicWording;+ _mp3IndexSeeking = mp3IndexSeek;_themeMode = theme == 'oled' ? 'dark' : theme;_flatBackground = flatBackground;_colorSource = colorSource == 'manual' ? 'manual' : 'dynamic';@@ -3495,6 +3498,25 @@ class _SettingsScreenState extends State<SettingsScreen> {applyTrustAllCerts(v);} : null,),+ if (Platform.isAndroid) ...[+ const Divider(height: 1, indent: 16, endIndent: 16),+ SwitchListTile(+ title: Row(children: [+ Flexible(child: Text(l.mp3IndexSeeking)),+ _infoIcon(l.mp3IndexSeekingInfoTitle, l.mp3IndexSeekingInfoContent),+ ]),+ subtitle: Text(+ _mp3IndexSeeking+ ? l.mp3IndexSeekingOnSubtitle+ : l.mp3IndexSeekingOffSubtitle,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),+ value: _mp3IndexSeeking,+ onChanged: _loaded ? (v) {+ setState(() => _mp3IndexSeeking = v);+ PlayerSettings.setMp3IndexSeeking(v);+ } : null,+ ),+ ],if (_isGithubBuild) ...[const Divider(height: 1, indent: 16, endIndent: 16),SwitchListTile(diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dartindex 1ef76099..79a89143 100644--- a/lib/services/audio_player_service.dart+++ b/lib/services/audio_player_service.dart@@ -1498,6 +1498,7 @@ class AudioPlayerService extends ChangeNotifier {.map((t) => AudioSource.uri(Uri.parse((t as Map<String, dynamic>)['url'] as String),headers: audioHeaders,+ options: mp3ExtractorOptions(),) as AudioSource).toList();}@@ -2998,7 +2999,7 @@ class AudioPlayerService extends ChangeNotifier {final track = t as Map<String, dynamic>;final contentUrl = track['contentUrl'] as String? ?? '';final fullUrl = api.buildTrackUrl(contentUrl);- trackSources.add(AudioSource.uri(Uri.parse(fullUrl), headers: audioHeaders));+ trackSources.add(AudioSource.uri(Uri.parse(fullUrl), headers: audioHeaders, options: mp3ExtractorOptions()));}source = ConcatenatingAudioSource(children: trackSources);@@ -3324,7 +3325,7 @@ class AudioPlayerService extends ChangeNotifier {final track = t as Map<String, dynamic>;final contentUrl = track['contentUrl'] as String? ?? '';final fullUrl = api.buildTrackUrl(contentUrl);- trackSources.add(AudioSource.uri(Uri.parse(fullUrl), headers: audioHeaders));+ trackSources.add(AudioSource.uri(Uri.parse(fullUrl), headers: audioHeaders, options: mp3ExtractorOptions()));}final source = ConcatenatingAudioSource(children: trackSources);@@ -3432,14 +3433,14 @@ class AudioPlayerService extends ChangeNotifier {final track = retryTracks.first as Map<String, dynamic>;final contentUrl = track['contentUrl'] as String? ?? '';final fullUrl = api.buildTrackUrl(contentUrl);- retrySource = AudioSource.uri(Uri.parse(fullUrl), headers: audioHeaders);+ retrySource = AudioSource.uri(Uri.parse(fullUrl), headers: audioHeaders, options: mp3ExtractorOptions());} else {final sources = <AudioSource>[];for (final t in retryTracks) {final track = t as Map<String, dynamic>;final contentUrl = track['contentUrl'] as String? ?? '';final fullUrl = api.buildTrackUrl(contentUrl);- sources.add(AudioSource.uri(Uri.parse(fullUrl), headers: audioHeaders));+ sources.add(AudioSource.uri(Uri.parse(fullUrl), headers: audioHeaders, options: mp3ExtractorOptions()));}retrySource = ConcatenatingAudioSource(children: sources);}@@ -3534,13 +3535,13 @@ class AudioPlayerService extends ChangeNotifier {if (retryTracks.length == 1) {final track = retryTracks.first as Map<String, dynamic>;final contentUrl = track['contentUrl'] as String? ?? '';- retrySource = AudioSource.uri(Uri.parse(api.buildTrackUrl(contentUrl)), headers: audioHeaders);+ retrySource = AudioSource.uri(Uri.parse(api.buildTrackUrl(contentUrl)), headers: audioHeaders, options: mp3ExtractorOptions());} else {final sources = <AudioSource>[];for (final t in retryTracks) {final track = t as Map<String, dynamic>;final contentUrl = track['contentUrl'] as String? ?? '';- sources.add(AudioSource.uri(Uri.parse(api.buildTrackUrl(contentUrl)), headers: audioHeaders));+ sources.add(AudioSource.uri(Uri.parse(api.buildTrackUrl(contentUrl)), headers: audioHeaders, options: mp3ExtractorOptions()));}retrySource = ConcatenatingAudioSource(children: sources);}diff --git a/lib/services/bookmark_preview_player.dart b/lib/services/bookmark_preview_player.dartindex 683a0691..ab1cdfb8 100644--- a/lib/services/bookmark_preview_player.dart+++ b/lib/services/bookmark_preview_player.dart@@ -119,8 +119,8 @@ class BookmarkPreviewPlayer extends ChangeNotifier {if (track.local) {await player.setAudioSource(localAudioSource(track.source));} else {- await player.setAudioSource(- AudioSource.uri(Uri.parse(track.source), headers: api?.mediaHeaders));+ await player.setAudioSource(AudioSource.uri(Uri.parse(track.source),+ headers: api?.mediaHeaders, options: mp3ExtractorOptions()));}_lastSeekMs = (local * 1000).round();await player.seek(Duration(milliseconds: _lastSeekMs!));diff --git a/lib/services/offline_source.dart b/lib/services/offline_source.dartindex 80703340..84306c47 100644--- a/lib/services/offline_source.dart+++ b/lib/services/offline_source.dart@@ -1,14 +1,28 @@import 'package:just_audio/just_audio.dart';+import 'player_settings.dart';+/// True when a stored download location is an Android Storage Access Framework/// content URI rather than a filesystem path. SAF custom folders store/// content:// URIs in DownloadInfo.localPaths; everything else (iOS app-group,/// Android internal and legacy downloads) stays a filesystem path.bool isContentUri(String pathOrUri) => pathOrUri.startsWith('content://');+/// Extractor options applied to every book/podcast audio source. Index+/// seeking fixes seek drift in VBR mp3s; opt-in because ExoPlayer builds the+/// index by reading the file, so a seek near the end of a large mp3 has to+/// read (and for streams, download) everything up to that point first.+/// Android-only - iOS ignores androidExtractorOptions.+ProgressiveAudioSourceOptions? mp3ExtractorOptions() =>+ PlayerSettings.mp3IndexSeeking+ ? const ProgressiveAudioSourceOptions(+ androidExtractorOptions: AndroidExtractorOptions(+ mp3Flags: AndroidExtractorOptions.flagMp3EnableIndexSeeking))+ : null;+/// Build the right AudioSource for a downloaded track. Content URIs play via/// AudioSource.uri (media3's ContentDataSource opens them through the persisted/// SAF permission); filesystem paths play via AudioSource.file.AudioSource localAudioSource(String pathOrUri) => isContentUri(pathOrUri)- ? AudioSource.uri(Uri.parse(pathOrUri))- : AudioSource.file(pathOrUri);+ ? AudioSource.uri(Uri.parse(pathOrUri), options: mp3ExtractorOptions())+ : AudioSource.file(pathOrUri, options: mp3ExtractorOptions());diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex 39009fed..158b9460 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -470,6 +470,14 @@ class PlayerSettings {await _set('showExplicitBadge', value);}+ /// Cached value for synchronous access when building audio sources.+ static bool mp3IndexSeeking = false;+ static Future<bool> getMp3IndexSeeking() => _get('mp3IndexSeeking', false);+ static Future<void> setMp3IndexSeeking(bool value) async {+ mp3IndexSeeking = value;+ await _set('mp3IndexSeeking', value);+ }+static Future<bool> getNotificationChapterProgress() => _get('notificationChapterProgress', false);static Future<void> setNotificationChapterProgress(bool value) => _set('notificationChapterProgress', value, notify: true);diff --git a/packages/just_audio/lib/just_audio.dart b/packages/just_audio/lib/just_audio.dartindex ed234c06..93408c01 100644--- a/packages/just_audio/lib/just_audio.dart+++ b/packages/just_audio/lib/just_audio.dart@@ -2294,7 +2294,9 @@ abstract class AudioSource {/// for background audio purposes, consider using the plugin audio_service/// instead of just_audio_background.static UriAudioSource uri(Uri uri,- {Map<String, String>? headers, dynamic tag}) {+ {Map<String, String>? headers,+ dynamic tag,+ ProgressiveAudioSourceOptions? options}) {bool hasExtension(Uri uri, String extension) =>uri.path.toLowerCase().endsWith('.$extension') ||uri.fragment.toLowerCase().endsWith('.$extension');@@ -2303,7 +2305,8 @@ abstract class AudioSource {} else if (hasExtension(uri, 'm3u8')) {return HlsAudioSource(uri, headers: headers, tag: tag);} else {- return ProgressiveAudioSource(uri, headers: headers, tag: tag);+ return ProgressiveAudioSource(uri,+ headers: headers, tag: tag, options: options);}}@@ -2314,8 +2317,9 @@ abstract class AudioSource {/// ```/// AudioSource.uri(Uri.file(filePath), tag: tag);/// ```- static UriAudioSource file(String filePath, {dynamic tag}) {- return AudioSource.uri(Uri.file(filePath), tag: tag);+ static UriAudioSource file(String filePath,+ {dynamic tag, ProgressiveAudioSourceOptions? options}) {+ return AudioSource.uri(Uri.file(filePath), tag: tag, options: options);}/// Convenience method to create an audio source for an asset.