Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

NowPlayingWidget: Saves last music player used to start it from the the touchBar + display album art if available #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

iamslan
Copy link

@iamslan iamslan commented Feb 27, 2019

No description provided.

Present in iTunes but not Deezer for example. Dictionnary key was kMRMediaRemoteNowPlayingInfoArtworkData
@iamslan iamslan changed the title NowPlayingWidget: Saves last music player used to start it from the the touchBar NowPlayingWidget: Saves last music player used to start it from the the touchBar + display album art if available Feb 27, 2019
@iamslan
Copy link
Author

iamslan commented Feb 27, 2019

Added fix for issue #36

Copy link
Owner

@billziss-gh billziss-gh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I have some review comments.

@@ -113,22 +117,27 @@ - (void)updateApp
NSString *appBundleIdentifier = nil;
NSString *appName = nil;
NSImage *appIcon = nil;

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the wrong place to be storing User Defaults. I would move them to the NowPlayingWidget itself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It tries to load the appBundleIdentifier of the last music player from the NSUserDefaults only if MRMediaRemoteGetNowPlayingClient returns nil.

It also saves the last music player used in NSUserDefaults on each updateApp.

It keeps the current implementation logic filling the appBundleIdentifier to get the name+icon of the application.

Let me know if you prefer to duplicate this logic in the NowPlayingWidget also.

src/System/NowPlaying.m Outdated Show resolved Hide resolved
src/System/NowPlaying.m Outdated Show resolved Hide resolved
@@ -155,12 +170,20 @@ - (void)updateInfo
NSString *album = [info objectForKey:kMRMediaRemoteNowPlayingInfoAlbum];
NSString *artist = [info objectForKey:kMRMediaRemoteNowPlayingInfoArtist];
NSString *title = [info objectForKey:kMRMediaRemoteNowPlayingInfoTitle];

if (self.album != album || self.artist != artist || self.title != title)
NSData *artworkData = [info objectForKey:kMRMediaRemoteNowPlayingInfoArtworkData];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is always nil on my machine. I am running macOS 10.14.3.

I have tried with iTunes, Spotify and Hermes and I never get the album art.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird, I'm also running macOS 10.14.3.

Logging info var using iTunes returns:
{
kMRMediaRemoteNowPlayingInfoAlbum = "Whatever People Say I Am, That's What I'm Not";
kMRMediaRemoteNowPlayingInfoAlbumiTunesStoreAdamIdentifier = 111153953;
kMRMediaRemoteNowPlayingInfoArtist = "Arctic Monkeys";
kMRMediaRemoteNowPlayingInfoArtistiTunesStoreAdamIdentifier = 62820413;
kMRMediaRemoteNowPlayingInfoArtworkData = <xxxxxxxx xxxxxxxx ...>
}

On my machine: https://www.youtube.com/watch?v=BEqfOcQq_Xk

src/System/NowPlaying.m Outdated Show resolved Hide resolved
src/Widgets/NowPlayingWidget.m Outdated Show resolved Hide resolved
@iamslan
Copy link
Author

iamslan commented Feb 28, 2019

Please check
5053265

@samabel
Copy link

samabel commented Sep 13, 2019

Hello you both, I am not a coding dude or sth else, but I really want to have this feature.

Can I download it somewhere, or how can I show the album art in the Energy bar?

Please help me.

@simonpacis
Copy link

@samabel I have built iamslan's pull request in an app for you. Download it and run it here. Open up the settings, go to the "Widgets" tab and enable "Show album art". Should work fine.

EnergyBar.app.zip

@samabel
Copy link

samabel commented Sep 24, 2019

@samabel I have built iamslan's pull request in an app for you. Download it and run it here. Open up the settings, go to the "Widgets" tab and enable "Show album art". Should work fine.

EnergyBar.app.zip

Hey @simonpacis, thank you very much for the work.

This works fine for me!

@fivestones
Copy link

Hey @simonpacis, any chance you could make a fork and put it all in there so we can all see the source for the zip you’re providing? Thanks for your work on this!

@simonpacis
Copy link

Hey @simonpacis, any chance you could make a fork and put it all in there so we can all see the source for the zip you’re providing? Thanks for your work on this!

I just built this fork: https://github.com/iamslan/EnergyBar. None of the code is mine. :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants