Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/providers/music_assistant_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,10 @@ class MusicAssistantProvider with ChangeNotifier {
if (baseUrl.endsWith('/')) {
baseUrl = baseUrl.substring(0, baseUrl.length - 1);
}
finalImageUrl = '$baseUrl/imageproxy?$queryString';
// Keep the original path: on MA 2.10+ it carries the proxy id
final imgPath = imgUri.path.isEmpty ? '/imageproxy' : imgUri.path;
finalImageUrl =
queryString.isEmpty ? '$baseUrl$imgPath' : '$baseUrl$imgPath?$queryString';
} catch (e) {
// Use original URL
}
Expand Down Expand Up @@ -3155,7 +3158,10 @@ class MusicAssistantProvider with ChangeNotifier {
if (baseUrl.endsWith('/')) {
baseUrl = baseUrl.substring(0, baseUrl.length - 1);
}
imageUrl = '$baseUrl/imageproxy?$queryString';
// Keep the original path: on MA 2.10+ it carries the proxy id
final imgPath = imgUri.path.isEmpty ? '/imageproxy' : imgUri.path;
imageUrl =
queryString.isEmpty ? '$baseUrl$imgPath' : '$baseUrl$imgPath?$queryString';
} catch (e) {
if (imageUrl != null && imageUrl.startsWith('http://')) {
imageUrl = imageUrl.replaceFirst('http://', 'https://');
Expand Down
21 changes: 20 additions & 1 deletion lib/services/music_assistant_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3250,6 +3250,18 @@ class MusicAssistantAPI {
return streamUrl;
}

// MA only accepts a fixed set of imageproxy sizes, so round up to the
// nearest supported one rather than letting the request 400 (0 = original).
static const _imageProxySizes = [80, 160, 256, 512, 1024];

int _imageProxySize(int size) {
if (size <= 0) return 0;
for (final supported in _imageProxySizes) {
if (size <= supported) return supported;
}
return _imageProxySizes.last;
}

// Get image URL
String? getImageUrl(MediaItem item, {int size = 256}) {
// Images are in metadata.images as an array
Expand Down Expand Up @@ -3315,8 +3327,15 @@ class MusicAssistantAPI {
baseUrl = '${uri.scheme}://${uri.host}:${uri.port}';
}

// MA 2.10 replaced the path+provider query form with /imageproxy/<proxy_id>
// and dropped the old one, so prefer proxy_id whenever the server sends it.
final proxyId = selectedImage['proxy_id'] as String?;
if (proxyId != null && proxyId.isNotEmpty) {
return '$baseUrl/imageproxy/$proxyId?size=${_imageProxySize(size)}&fmt=jpeg';
}

final provider = selectedImage['provider'] as String?;
// Use the imageproxy endpoint
// Pre-2.10 servers don't expose proxy_id; fall back to the legacy endpoint
return '$baseUrl/imageproxy?provider=${Uri.encodeComponent(provider ?? "")}&size=$size&fmt=jpeg&path=${Uri.encodeComponent(imagePath)}';
}

Expand Down