Skip to content

Commit

Permalink
Improved code (Early return while building audio source)
Browse files Browse the repository at this point in the history
  • Loading branch information
gokadzev committed Jan 28, 2024
1 parent ff0eeb0 commit 36fc9bf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/services/audio_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ class MusifyAudioHandler extends BaseAudioHandler {
final tag = mapToMediaItem(song, songUrl);
final audioSource = AudioSource.uri(uri, tag: tag);

if (!isOffline && sponsorBlockSupport.value) {
final spbAudioSource =
await checkIfSponsorBlockIsAvailable(audioSource, song['ytid']);
return spbAudioSource ?? audioSource;
if (isOffline || !sponsorBlockSupport.value) {
return audioSource;
}

return audioSource;
final spbAudioSource =
await checkIfSponsorBlockIsAvailable(audioSource, song['ytid']);
return spbAudioSource ?? audioSource;
}

Future<ClippingAudioSource?> checkIfSponsorBlockIsAvailable(
Expand Down

0 comments on commit 36fc9bf

Please sign in to comment.