-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added app volume and pan setting to AppleScript
- Loading branch information
Marcus Wu
committed
Mar 20, 2021
1 parent
2ff4c08
commit 9765193
Showing
12 changed files
with
285 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// BGMASApplication.h | ||
// Background Music | ||
// | ||
// Created by Marcus Wu on 3/17/21. | ||
// Copyright © 2021 Background Music contributors. All rights reserved. | ||
// | ||
|
||
// Local Includes | ||
#import "BGMAppVolumesController.h" | ||
|
||
// System Includes | ||
#import <Foundation/Foundation.h> | ||
#import <Cocoa/Cocoa.h> | ||
|
||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface BGMASApplication : NSObject | ||
|
||
- (instancetype) initWithApplication:(NSRunningApplication*)app | ||
volumeController:(BGMAppVolumesController*)volumeController | ||
parentSpecifier:(NSScriptObjectSpecifier* __nullable)parentSpecifier | ||
index:(int)i; | ||
|
||
@property (readonly) NSString* name; | ||
@property int volume; | ||
@property int pan; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// | ||
// BGMASApplication.m | ||
// Background Music | ||
// | ||
// Created by Marcus Wu on 3/17/21. | ||
// Copyright © 2021 Background Music contributors. All rights reserved. | ||
// | ||
|
||
// Self Include | ||
#import "BGMASApplication.h" | ||
|
||
@implementation BGMASApplication { | ||
NSScriptObjectSpecifier* parentSpecifier; | ||
NSRunningApplication *application; | ||
BGMAppVolumesController* appVolumesController; | ||
int index; | ||
} | ||
|
||
- (instancetype) initWithApplication:(NSRunningApplication*)app | ||
volumeController:(BGMAppVolumesController*)volumeController | ||
parentSpecifier:(NSScriptObjectSpecifier* __nullable)parent | ||
index:(int)i { | ||
if ((self = [super init])) { | ||
parentSpecifier = parent; | ||
application = app; | ||
appVolumesController = volumeController; | ||
index = i; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (NSString*) name { | ||
return [NSString stringWithFormat:@"%@", [application localizedName]]; | ||
} | ||
|
||
- (int) volume { | ||
return [appVolumesController getVolumeAndPanForApp:application].volume; | ||
} | ||
|
||
- (void) setVolume:(int)vol { | ||
BGMAppVolumeAndPan volume = { | ||
.volume = vol, | ||
.pan = -1 | ||
}; | ||
[appVolumesController setVolumeAndPan:volume forApp:application]; | ||
} | ||
|
||
- (int) pan { | ||
return [appVolumesController getVolumeAndPanForApp:application].pan; | ||
} | ||
|
||
- (void) setPan:(int)pan { | ||
BGMAppVolumeAndPan thePan = { | ||
.volume = -1, | ||
.pan = pan | ||
}; | ||
[appVolumesController setVolumeAndPan:thePan forApp:application]; | ||
} | ||
|
||
- (NSScriptObjectSpecifier* __nullable) objectSpecifier { | ||
NSScriptClassDescription* parentClassDescription = [parentSpecifier keyClassDescription]; | ||
return [[NSNameSpecifier alloc] initWithContainerClassDescription:parentClassDescription | ||
containerSpecifier:parentSpecifier | ||
key:@"applications" | ||
name:self.name]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.