From f1036ff075a5ce5267543b8d315b295bc99f3b94 Mon Sep 17 00:00:00 2001 From: Komodo <45665554+Komodo5197@users.noreply.github.com> Date: Sat, 25 May 2024 18:20:36 -0400 Subject: [PATCH] Add comments. --- lib/components/PlayerScreen/feature_chips.dart | 4 ++++ lib/services/metadata_provider.dart | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/components/PlayerScreen/feature_chips.dart b/lib/components/PlayerScreen/feature_chips.dart index c66212a2..29ef8a8e 100644 --- a/lib/components/PlayerScreen/feature_chips.dart +++ b/lib/components/PlayerScreen/feature_chips.dart @@ -40,6 +40,10 @@ class FeatureState { ? null : metadata?.mediaSourceInfo.mediaStreams .firstWhereOrNull((stream) => stream.type == "Audio"); + // Transcoded downloads will not have a valid MediaStream, but will have + // the target transcode bitrate set for the mediasource bitrate. Other items + // should have a valid mediaStream, so use that audio-only bitrate instead of the + // whole-file bitrate. int? get bitrate => isTranscoding ? settings.transcodeBitrate : audioStream?.bitRate ?? metadata?.mediaSourceInfo.bitrate; diff --git a/lib/services/metadata_provider.dart b/lib/services/metadata_provider.dart index 7c2c0851..9d202822 100644 --- a/lib/services/metadata_provider.dart +++ b/lib/services/metadata_provider.dart @@ -40,6 +40,9 @@ class MetadataRequest { item.id, queueItem?.id, includeLyrics, checkIfSpeedControlNeeded); } +/// A storage container for metadata about a song. The codec information will reflect +/// the downloaded file if appropriate, even for transcoded downloads. Online +/// transcoding will not be reflected. class MetadataProvider { static const speedControlGenres = ["audiobook", "podcast", "speech"]; static const speedControlLongTrackDuration = Duration(minutes: 15); @@ -93,6 +96,8 @@ final AutoDisposeFutureProviderFamily ? profile?.stereoBitrate : downloadItem.baseItem!.mediaSources?.first.bitrate; + // We cannot create a fully accurate MediaStream for a transcoded item, so + // just return an empty list. List mediaStream = profile?.codec != FinampTranscodingCodec.original ? []