Skip to content
This repository was archived by the owner on Mar 28, 2026. It is now read-only.

Commit 11cbc15

Browse files
authored
Merge pull request #1092 from jellyfin/mac-artwork
Set player artwork on macos
2 parents cb42350 + d3858e2 commit 11cbc15

File tree

13 files changed

+418
-2053
lines changed

13 files changed

+418
-2053
lines changed

resources/settings/settings_description.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,13 +656,12 @@
656656
]
657657
},
658658
{
659-
"section": "mpris",
659+
"section": "albumart",
660660
"hidden": true,
661-
"platforms": [ "linux" ],
662661
"values": [
663662
{
664-
"value": "albumArtCacheSize",
665-
"default": 52428800
663+
"value": "cacheSize",
664+
"default": 10485760
666665
}
667666
]
668667
},

src/input/apple/InputAppleMediaKeys.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ private slots:
2121
void handlePositionUpdate(quint64 position);
2222
void handleUpdateDuration(qint64 duration);
2323
void handleUpdateMetaData(const QVariantMap& meta);
24+
void handleAlbumArtReady(const QByteArray& imageData, const QString& mimeType);
25+
void handleAlbumArtUnavailable();
2426

2527
private:
2628
void* m_delegate;

src/input/apple/InputAppleMediaKeys.mm

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
//
44

55
#include "InputAppleMediaKeys.h"
6+
#include "player/AlbumArtProvider.h"
67
#include <QDebug>
78

89
#import <dlfcn.h>
910

11+
#import <AppKit/AppKit.h>
1012
#import <MediaPlayer/MediaPlayer.h>
1113

1214
@interface MediaKeysDelegate : NSObject
@@ -98,6 +100,15 @@ -(MPRemoteCommandHandlerStatus)gotPlaybackPosition:(MPChangePlaybackPositionComm
98100
connect(&PlayerComponent::Get(), &PlayerComponent::onMetaData, this,
99101
&InputAppleMediaKeys::handleUpdateMetaData);
100102

103+
// Connect to AlbumArtProvider signals
104+
if (PlayerComponent::Get().albumArtProvider())
105+
{
106+
connect(PlayerComponent::Get().albumArtProvider(), &AlbumArtProvider::artworkReady,
107+
this, &InputAppleMediaKeys::handleAlbumArtReady);
108+
connect(PlayerComponent::Get().albumArtProvider(), &AlbumArtProvider::artworkUnavailable,
109+
this, &InputAppleMediaKeys::handleAlbumArtUnavailable);
110+
}
111+
101112
if (auto lib =
102113
dlopen("/System/Library/PrivateFrameworks/MediaRemote.framework/MediaRemote", RTLD_NOW))
103114
{
@@ -207,3 +218,36 @@ static MPNowPlayingPlaybackState convertState(PlayerComponent::State newState)
207218

208219
MPNowPlayingInfoCenter.defaultCenter.nowPlayingInfo = info;
209220
}
221+
222+
///////////////////////////////////////////////////////////////////////////////////////////////////
223+
void InputAppleMediaKeys::handleAlbumArtReady(const QByteArray& imageData, const QString& mimeType)
224+
{
225+
// Convert QByteArray to NSData
226+
NSData *nsImageData = [NSData dataWithBytes:imageData.constData() length:imageData.size()];
227+
228+
// Create NSImage from the data
229+
NSImage *nsImage = [[NSImage alloc] initWithData:nsImageData];
230+
if (!nsImage)
231+
{
232+
qDebug() << "AppleMediaKeys: Failed to create NSImage from album art data";
233+
return;
234+
}
235+
236+
// Create MPMediaItemArtwork from NSImage
237+
MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc] initWithBoundsSize:nsImage.size
238+
requestHandler:^NSImage * _Nonnull(CGSize size) {
239+
return nsImage;
240+
}];
241+
242+
// Update now playing info with artwork
243+
auto info = [NSMutableDictionary
244+
dictionaryWithDictionary:MPNowPlayingInfoCenter.defaultCenter.nowPlayingInfo];
245+
info[MPMediaItemPropertyArtwork] = artwork;
246+
MPNowPlayingInfoCenter.defaultCenter.nowPlayingInfo = info;
247+
}
248+
249+
///////////////////////////////////////////////////////////////////////////////////////////////////
250+
void InputAppleMediaKeys::handleAlbumArtUnavailable()
251+
{
252+
// No action needed - metadata remains without artwork
253+
}

src/main.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <QDebug>
2121
#include "Paths.h"
2222
#include "core/ProfileManager.h"
23-
#include "player/CodecsComponent.h"
2423
#include "player/PlayerComponent.h"
2524
#include "player/OpenGLDetect.h"
2625
#include "display/DisplayComponent.h"
@@ -493,8 +492,6 @@ int main(int argc, char *argv[])
493492

494493
qInfo() << "Config directory:" << qPrintable(ProfileManager::activeProfile().dataDir());
495494

496-
Codecs::preinitCodecs();
497-
498495
Log::ApplyConfigLogLevel();
499496

500497
SettingsComponent::Get().setCommandLineValues(parser.optionNames());
@@ -592,7 +589,6 @@ int main(int argc, char *argv[])
592589
delete uniqueApp;
593590
Globals::EngineDestroy();
594591

595-
Codecs::Uninit();
596592
return ret;
597593
}
598594
catch (FatalException& e)
@@ -605,7 +601,6 @@ int main(int argc, char *argv[])
605601

606602
errApp.exec();
607603

608-
Codecs::Uninit();
609604
return 1;
610605
}
611606
}

0 commit comments

Comments
 (0)