Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to pause the Apple Music app when joining a meeting #91

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions MeetingBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
40DC7051250E5DB500217DD9 /* AutoLauncher.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 40DC7040250E5B9C00217DD9 /* AutoLauncher.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
40DC7054250E5E1000217DD9 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 40DC7053250E5E1000217DD9 /* ServiceManagement.framework */; };
40E60313250E81EA005986C7 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40E60312250E81EA005986C7 /* main.swift */; };
67EABB392530FF29001DDFEE /* MusicScripting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EABB372530FF28001DDFEE /* MusicScripting.swift */; };
67EABB3A2530FF29001DDFEE /* Music.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EABB382530FF28001DDFEE /* Music.swift */; };
67EABB3E2530FF31001DDFEE /* MusicController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EABB3D2530FF31001DDFEE /* MusicController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -65,6 +68,9 @@
40DC704C250E5BB100217DD9 /* AutoLauncher.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AutoLauncher.entitlements; sourceTree = "<group>"; };
40DC7053250E5E1000217DD9 /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; };
40E60312250E81EA005986C7 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
67EABB372530FF28001DDFEE /* MusicScripting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MusicScripting.swift; sourceTree = "<group>"; };
67EABB382530FF28001DDFEE /* Music.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Music.swift; sourceTree = "<group>"; };
67EABB3D2530FF31001DDFEE /* MusicController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MusicController.swift; sourceTree = "<group>"; };
E4DD0F0A2529D0D20029E395 /* Project-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Project-Release.xcconfig"; sourceTree = "<group>"; };
E4DD0F0B2529D0D20029E395 /* Project.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Project.xcconfig; sourceTree = "<group>"; };
E4DD0F0C2529D0D20029E395 /* Project-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Project-Debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -125,6 +131,7 @@
144C017B2462D0C3000C9FFC /* MeetingBar */ = {
isa = PBXGroup;
children = (
67EABB362530FF28001DDFEE /* ScriptingBridge */,
14E4110D246F2F9200F73ACF /* PreferencesView.swift */,
148E47E724F400C400399929 /* OnboardingView.swift */,
144C017C2462D0C3000C9FFC /* AppDelegate.swift */,
Expand All @@ -136,6 +143,7 @@
140D84332493A4180055E1CE /* Constants.swift */,
144C01892462D0C5000C9FFC /* MeetingBar.entitlements */,
140D84392493A6240055E1CE /* Helpers.swift */,
67EABB3D2530FF31001DDFEE /* MusicController.swift */,
14879B2A24E6889C00DB0A7E /* Notifications.swift */,
144C01822462D0C5000C9FFC /* Preview Content */,
);
Expand Down Expand Up @@ -169,6 +177,15 @@
name = Frameworks;
sourceTree = "<group>";
};
67EABB362530FF28001DDFEE /* ScriptingBridge */ = {
isa = PBXGroup;
children = (
67EABB372530FF28001DDFEE /* MusicScripting.swift */,
67EABB382530FF28001DDFEE /* Music.swift */,
);
path = ScriptingBridge;
sourceTree = "<group>";
};
E4DD0F092529D0D20029E395 /* XCConfig */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -317,8 +334,11 @@
140D84412493B8030055E1CE /* KeyboardShortcutsNames.swift in Sources */,
140D843D2493B7BF0055E1CE /* EventStore.swift in Sources */,
14E4110E246F2F9200F73ACF /* PreferencesView.swift in Sources */,
67EABB392530FF29001DDFEE /* MusicScripting.swift in Sources */,
67EABB3E2530FF31001DDFEE /* MusicController.swift in Sources */,
140D84322493A3FE0055E1CE /* StatusBarItemControler.swift in Sources */,
140D84342493A4180055E1CE /* Constants.swift in Sources */,
67EABB3A2530FF29001DDFEE /* Music.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
5 changes: 5 additions & 0 deletions MeetingBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
@objc
func createMeeting(_: Any? = nil) {
NSLog("Create meeting in \(Defaults[.createMeetingService].rawValue)")

if Defaults[.pauseMusicOnJoin] {
MusicController.pauseMusic()
}

switch Defaults[.createMeetingService] {
case .meet:
openMeetingURL(MeetingServices.meet, CreateMeetingLinks.meet)
Expand Down
3 changes: 3 additions & 0 deletions MeetingBar/DefaultsKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ extension Defaults.Keys {
static let useChromeForHangoutsLinks = Key<Bool>("useChromeForHangoutsLinks", default: false)
static let useAppForZoomLinks = Key<Bool>("useAppForZoomLinks", default: false)
static let useAppForTeamsLinks = Key<Bool>("useAppForTeamsLinks", default: false)

// Actions
static let pauseMusicOnJoin = Key<Bool>("pauseMusicOnJoin", default: false)
}
2 changes: 2 additions & 0 deletions MeetingBar/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSAppleEventsUsageDescription</key>
<string>Pause the currently playing track in the Apple Music app</string>
<key>NSCalendarsUsageDescription</key>
<string>To get events to show on status bar</string>
<key>NSHumanReadableCopyright</key>
Expand Down
6 changes: 1 addition & 5 deletions MeetingBar/MeetingBar.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.personal-information.calendars</key>
<key>com.apple.security.automation.apple-events</key>
<true/>
</dict>
</plist>
21 changes: 21 additions & 0 deletions MeetingBar/MusicController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Music.swift
// MeetingBar
//
// Created by Colin Edwards on 10/9/20.
// Copyright © 2020 Andrii Leitsius. All rights reserved.
//

import Foundation
import ScriptingBridge

class MusicController {
static func pauseMusic() {
if let application = SBApplication(bundleIdentifier: "com.apple.Music") {
if application.isRunning {
let music = application as MusicApplication
music.pause?()
}
}
}
}
20 changes: 20 additions & 0 deletions MeetingBar/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct PreferencesView: View {
Appearance().tabItem { Text("Appearance") }
Configuration().tabItem { Text("Services") }
Calendars().padding().tabItem { Text("Calendars") }
Actions().padding().tabItem { Text("Actions") }
}
}.padding()
}
Expand Down Expand Up @@ -332,3 +333,22 @@ func emailMe() {
NSLog("Click email me")
_ = openLinkInDefaultBrowser(Links.emailMe)
}

struct PreferencesView_Previews: PreviewProvider {
static var previews: some View {
/*@START_MENU_TOKEN@*/Text("Hello, World!")/*@END_MENU_TOKEN@*/
}
}

struct Actions: View {
@Default(.pauseMusicOnJoin) var pauseMusicOnJoin

var body: some View {
VStack(alignment: .leading, spacing: 15) {
Section {
Toggle("Pause music on join", isOn: $pauseMusicOnJoin)
}
Spacer()
}.padding()
}
}