mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-05 23:19:42 +00:00
fix: quality preset initialization fails and audio source auth
This commit is contained in:
parent
4b5108e54e
commit
6272f376ea
1
android/.gitignore
vendored
1
android/.gitignore
vendored
@ -11,3 +11,4 @@ GeneratedPluginRegistrant.java
|
||||
key.properties
|
||||
**/*.keystore
|
||||
**/*.jks
|
||||
.kotlin
|
||||
@ -44,7 +44,7 @@ class SpotubeAudioLossyContainerQuality
|
||||
|
||||
@override
|
||||
toString() {
|
||||
return "${oneOptionalDecimalFormatter.format(bitrate)}kbps";
|
||||
return "${oneOptionalDecimalFormatter.format(bitrate / 1000)}kbps";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -52,9 +52,10 @@ class MetadataInstalledPluginItem extends HookConsumerWidget {
|
||||
ref.watch(metadataPluginAuthenticatedProvider);
|
||||
final isAudioSourceAuthenticatedSnapshot =
|
||||
ref.watch(audioSourcePluginAuthenticatedProvider);
|
||||
final isAuthenticated =
|
||||
isMetadataAuthenticatedSnapshot.asData?.value == true ||
|
||||
isAudioSourceAuthenticatedSnapshot.asData?.value == true;
|
||||
final isAuthenticated = (isDefaultMetadata &&
|
||||
isMetadataAuthenticatedSnapshot.asData?.value == true) ||
|
||||
(isDefaultAudioSource &&
|
||||
isAudioSourceAuthenticatedSnapshot.asData?.value == true);
|
||||
|
||||
final metadataUpdateAvailable =
|
||||
ref.watch(metadataPluginUpdateCheckerProvider);
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:spotube/models/metadata/metadata.dart';
|
||||
import 'package:spotube/provider/metadata_plugin/metadata_plugin_provider.dart';
|
||||
import 'package:spotube/services/audio_player/audio_player.dart';
|
||||
import 'package:spotube/services/metadata/metadata.dart';
|
||||
|
||||
part 'quality_presets.g.dart';
|
||||
part 'quality_presets.freezed.dart';
|
||||
@ -28,9 +29,13 @@ class AudioSourceAvailableQualityPresetsNotifier
|
||||
extends Notifier<AudioSourcePresetsState> {
|
||||
@override
|
||||
build() {
|
||||
ref.watch(audioSourcePluginProvider);
|
||||
final audioSourceSnapshot = ref.watch(audioSourcePluginProvider);
|
||||
final audioSourceConfigSnapshot = ref.watch(
|
||||
metadataPluginsProvider.select((data) =>
|
||||
data.whenData((value) => value.defaultAudioSourcePluginConfig)),
|
||||
);
|
||||
|
||||
_initialize();
|
||||
_initialize(audioSourceSnapshot, audioSourceConfigSnapshot);
|
||||
|
||||
listenSelf((previous, next) {
|
||||
final isNewLossless =
|
||||
@ -49,12 +54,12 @@ class AudioSourceAvailableQualityPresetsNotifier
|
||||
return AudioSourcePresetsState();
|
||||
}
|
||||
|
||||
void _initialize() async {
|
||||
final audioSource = await ref.read(audioSourcePluginProvider.future);
|
||||
final audioSourceConfig = await ref.read(
|
||||
metadataPluginsProvider
|
||||
.selectAsync((data) => data.defaultAudioSourcePluginConfig),
|
||||
);
|
||||
void _initialize(
|
||||
AsyncValue<MetadataPlugin?> audioSourceSnapshot,
|
||||
AsyncValue<PluginConfiguration?> audioSourceConfigSnapshot,
|
||||
) async {
|
||||
audioSourceConfigSnapshot.whenData((audioSourceConfig) {
|
||||
audioSourceSnapshot.whenData((audioSource) async {
|
||||
if (audioSource == null || audioSourceConfig == null) {
|
||||
throw Exception("Dude wat?");
|
||||
}
|
||||
@ -63,12 +68,15 @@ class AudioSourceAvailableQualityPresetsNotifier
|
||||
preferences.getString("audioSourceState-${audioSourceConfig.slug}");
|
||||
|
||||
if (persistedStateStr != null) {
|
||||
state = AudioSourcePresetsState.fromJson(jsonDecode(persistedStateStr));
|
||||
state =
|
||||
AudioSourcePresetsState.fromJson(jsonDecode(persistedStateStr));
|
||||
} else {
|
||||
state = AudioSourcePresetsState(
|
||||
presets: audioSource.audioSource.supportedPresets,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void setSelectedStreamingContainerIndex(int index) {
|
||||
|
||||
@ -65,6 +65,6 @@ class AudioSourcePluginAuthenticatedNotifier extends AsyncNotifier<bool> {
|
||||
}
|
||||
|
||||
final audioSourcePluginAuthenticatedProvider =
|
||||
AsyncNotifierProvider<MetadataPluginAuthenticatedNotifier, bool>(
|
||||
MetadataPluginAuthenticatedNotifier.new,
|
||||
AsyncNotifierProvider<AudioSourcePluginAuthenticatedNotifier, bool>(
|
||||
AudioSourcePluginAuthenticatedNotifier.new,
|
||||
);
|
||||
|
||||
@ -48,7 +48,7 @@ class ServerPlaybackRoutes {
|
||||
return join(
|
||||
await UserPreferencesNotifier.getMusicCacheDir(),
|
||||
ServiceUtils.sanitizeFilename(
|
||||
'${track.query.name} - ${track.query.artists.join(",")} (${track.info.id}).${track.qualityPreset!.name}',
|
||||
'${track.query.name} - ${track.query.artists.map((d) => d.name).join(",")} (${track.info.id}).${track.qualityPreset!.name}',
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -288,7 +288,9 @@ class ServerPlaybackRoutes {
|
||||
imageBytes: imageBytes,
|
||||
fileLength: fileLength,
|
||||
),
|
||||
);
|
||||
).catchError((e, stackTrace) {
|
||||
AppLogger.reportError(e, stackTrace);
|
||||
});
|
||||
}
|
||||
|
||||
return (bytes: bytes, response: res);
|
||||
|
||||
@ -317,7 +317,7 @@ class SourcedTrack extends BasicSourcedTrack {
|
||||
source.bitDepth == quality.bitDepth;
|
||||
} else {
|
||||
return source.bitrate ==
|
||||
(preset as SpotubeAudioLossyContainerQuality).bitrate;
|
||||
(quality as SpotubeAudioLossyContainerQuality).bitrate;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user