Skip to content

Commit

Permalink
Add Music.app support
Browse files Browse the repository at this point in the history
  • Loading branch information
天々座理世 authored and 天々座理世 committed Dec 28, 2019
1 parent 508b6de commit db4a91d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SwinsianDiscord.xcodeproj/project.xcworkspace/xcuserdata/tedezarize.xcuserdatad/UserInterfaceState.xcuserstate
SwinsianDiscord.xcodeproj/xcuserdata/tedezarize.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
SwinsianDiscord.xcodeproj/xcuserdata/tedezarize.xcuserdatad/xcschemes/xcschememanagement.plist
.DS_Store
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# SwinsianDiscord
![screnshot](https://malupdaterosx.moe/wp-content/uploads/2019/05/SwinsianDiscord.png)

SwinsianDiscord is a simple menubar app for macOS that allows you to share what you are playing in Swinsian or iTunes in Discord via Rich Presence. [Swinsian](https://swinsian.com) is a Advanced Music Player for Mac.
SwinsianDiscord is a simple menubar app for macOS that allows you to share what you are playing in Swinsian or iTunes/Music App in Discord via Rich Presence. [Swinsian](https://swinsian.com) is a Advanced Music Player for Mac.

This program works on macOS El Capitan or later and requires Swinsian version >= 1.8.8 or Apple iTunes to work.
This program works on macOS El Capitan or later and requires Swinsian version >= 1.8.8 or Apple iTunes to work. Music.app suppport requires macOS 10.15 Catalina, but it does not support elapsed time due to the app not providing that information.

The logo and the program name, Swinsian is owned by the respective owners.

Expand Down
4 changes: 4 additions & 0 deletions SwinsianDiscord.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 9HDZTER525;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -348,6 +349,7 @@
);
INFOPLIST_FILE = "$(SRCROOT)/SwinsianDiscord/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MARKETING_VERSION = 1.2.1;
PRODUCT_BUNDLE_IDENTIFIER = pro.moyit.iTunesDiscord;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -359,6 +361,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 9HDZTER525;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -368,6 +371,7 @@
);
INFOPLIST_FILE = "$(SRCROOT)/SwinsianDiscord/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MARKETING_VERSION = 1.2.1;
PRODUCT_BUNDLE_IDENTIFIER = pro.moyit.iTunesDiscord;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
19 changes: 18 additions & 1 deletion SwinsianDiscord/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
selector:@selector(playerInfoChanged:)
name:@"com.apple.iTunes.playerInfo"
object:nil];
if (@available(macOS 10.5, *)) {
[center addObserver:self
selector:@selector(playerInfoChanged:)
name:@"com.apple.Music.playerInfo"
object:nil];
}
else {
[center addObserver:self
selector:@selector(playerInfoChanged:)
name:@"com.apple.iTunes.playerInfo"
object:nil];
}
}


Expand Down Expand Up @@ -157,7 +169,12 @@ - (void)playerInfoChanged:(NSNotification *)theNotification

if ([(NSString *)info[@"Player State"] isEqualToString:@"Playing"]) {
if (_dm.getStarted) {
[self.dm UpdatePresence:[NSString stringWithFormat:@"by %@ \n- %@",info[@"Artist"],info[@"Album"]] withDetails:info[@"Name"] withLargeImage:@"itunes" withCurrentPosition:[self convertElaspedTimeToInterval:info[@"elapsedStr"]]];
if (@available(macOS 10.5, *)) {
[self.dm UpdatePresence:[NSString stringWithFormat:@"by %@ \n- %@",info[@"Artist"],info[@"Album"]] withDetails:info[@"Name"] withLargeImage:@"itunes" withCurrentPosition:0];
}
else {
[self.dm UpdatePresence:[NSString stringWithFormat:@"by %@ \n- %@",info[@"Artist"],info[@"Album"]] withDetails:info[@"Name"] withLargeImage:@"itunes" withCurrentPosition:[self convertElaspedTimeToInterval:info[@"elapsedStr"]]];
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions SwinsianDiscord/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>5</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
Expand Down

0 comments on commit db4a91d

Please sign in to comment.