From e46873ffad23eec330fd82bb23cc7eeb6e9f5b24 Mon Sep 17 00:00:00 2001 From: Ben Hills Date: Tue, 27 Aug 2024 16:00:54 +0100 Subject: [PATCH] When playing an episode, always take the duration from the MP3 if available. Fixes issue where duration in RSS may be very different to that of the actual MP3 once DAI had been applied. --- lib/services/audio/default_audio_player_service.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/services/audio/default_audio_player_service.dart b/lib/services/audio/default_audio_player_service.dart index f60bca01..65959802 100644 --- a/lib/services/audio/default_audio_player_service.dart +++ b/lib/services/audio/default_audio_player_service.dart @@ -872,9 +872,9 @@ class _DefaultAudioPlayerHandler extends BaseAudioHandler with SeekHandler { try { var duration = await _player.setAudioSource(source, initialPosition: start); - /// If we don't already have a duration and we have been able to calculate it from - /// beginning to fetch the media, update the current media item with the duration. - if (duration != null && (_currentItem!.duration == null || _currentItem!.duration!.inSeconds == 0)) { + /// As duration returned from the player library can be different from the duration in the feed - usually + /// because of DAI - if we have a duration from the player, use that. + if (duration != null) { _currentItem = _currentItem!.copyWith(duration: duration); }