Added now playing spam hotkey, currently format hard coded

CQTexperiment
Chris Moeller 2013-10-04 04:16:09 -07:00
parent a5d8401477
commit 7c5eaed629
11 changed files with 277 additions and 71 deletions

View File

@ -45,6 +45,7 @@
NDHotKeyEvent *playHotKey;
NDHotKeyEvent *prevHotKey;
NDHotKeyEvent *nextHotKey;
NDHotKeyEvent *spamHotKey;
AppleRemote *remote;
BOOL remoteButtonHeld; /* true as long as the user holds the left,right,plus or minus on the remote control */
@ -78,6 +79,7 @@ OSStatus handleHotKey(EventHandlerCallRef nextHandler,EventRef theEvent,void *us
- (void)clickPlay;
- (void)clickPrev;
- (void)clickNext;
- (void)clickSpam;
- (IBAction)increaseFontSize:(id)sender;
- (IBAction)decreaseFontSize:(id)sender;

View File

@ -358,6 +358,19 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[userDefaultsValuesDict setObject:@"enqueue" forKey:@"openingFilesAlteredBehavior"];
[userDefaultsValuesDict setObject:@"albumGainWithPeak" forKey:@"volumeScaling"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyPlayKeyCode"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyPlayCharacter"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyPlayModifiers"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyNextKeyCode"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyNextCharacter"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyNextModifiers"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyPreviousKeyCode"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyPreviousCharacter"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeyPreviousModifiers"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeySpamKeyCode"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeySpamCharacter"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:0] forKey:@"hotKeySpamModifiers"];
//Register and sync defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
@ -367,6 +380,8 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.hotKeyPlayKeyCode" options:0 context:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.hotKeyPreviousKeyCode" options:0 context:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.hotKeyNextKeyCode" options:0 context:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self
forKeyPath:@"values.hotKeySpamKeyCode" options:0 context:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.remoteEnabled" options:0 context:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.remoteOnlyOnActive" options:0 context:nil];
@ -386,6 +401,9 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
else if ([keyPath isEqualToString:@"values.hotKeyNextKeyCode"]) {
[self registerHotKeys];
}
else if ([keyPath isEqualToString:@"values.hotKeySpamKeyCode"]) {
[self registerHotKeys];
}
else if ([keyPath isEqualToString:@"values.remoteEnabled"] || [keyPath isEqualToString:@"values.remoteOnlyOnActive"]) {
if([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"]) {
BOOL onlyOnActive = [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"];
@ -405,33 +423,48 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
- (void)registerHotKeys
{
[playHotKey release];
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayKeyCode"] intValue]) {
playHotKey = [[NDHotKeyEvent alloc]
initWithKeyCode: [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayKeyCode"] intValue]
character: [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayCharacter"] intValue]
modifierFlags: [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayModifiers"] intValue]
];
[playHotKey setTarget:self selector:@selector(clickPlay)];
[playHotKey setEnabled:YES];
}
[prevHotKey release];
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPreviousKeyCode"] intValue]) {
prevHotKey = [[NDHotKeyEvent alloc]
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousKeyCode"]
character: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousCharacter"]
modifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousModifiers"]
];
[prevHotKey setTarget:self selector:@selector(clickPrev)];
[prevHotKey setEnabled:YES];
}
[nextHotKey release];
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyNextKeyCode"] intValue]) {
nextHotKey = [[NDHotKeyEvent alloc]
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyNextKeyCode"]
character: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyNextCharacter"]
modifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyNextModifiers"]
];
[playHotKey setTarget:self selector:@selector(clickPlay)];
[prevHotKey setTarget:self selector:@selector(clickPrev)];
[nextHotKey setTarget:self selector:@selector(clickNext)];
[playHotKey setEnabled:YES];
[prevHotKey setEnabled:YES];
[nextHotKey setEnabled:YES];
[nextHotKey setTarget:self selector:@selector(clickNext)];
[nextHotKey setEnabled:YES];
}
[spamHotKey release];
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeySpamKeyCode"] intValue]) {
spamHotKey = [[NDHotKeyEvent alloc]
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamKeyCode"]
character: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamCharacter"]
modifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamModifiers"]
];
[spamHotKey setTarget:self selector:@selector(clickSpam)];
[spamHotKey setEnabled:YES];
}
}
- (void)clickPlay
@ -449,6 +482,11 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[playbackController next:nil];
}
- (void)clickSpam
{
[playbackController spam];
}
- (void)changeFontSize:(float)size
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

View File

@ -63,6 +63,8 @@ extern NSDictionary * makeRGInfo(PlaylistEntry *pe);
- (void)seekBackward:(double)amount;
- (IBAction)fade:(id)sender;
- (IBAction)spam;
- (void)initDefaults;
- (void)audioFadeDown:(NSTimer *)audioTimer;
- (void)audioFadeUp:(NSTimer *)audioTimer;

View File

@ -170,6 +170,8 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
double pos = [audioPlayer amountPlayed];
[self setPosition:pos];
[[playlistController currentEntry] setCurrentPosition:pos];
}
- (IBAction)seek:(id)sender
@ -177,7 +179,17 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
double time = [sender doubleValue];
[audioPlayer seekToTime:time];
[[playlistController currentEntry] setCurrentPosition:time];
}
- (IBAction)spam
{
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
[pboard clearContents];
[pboard writeObjects:[NSArray arrayWithObjects:[[playlistController currentEntry] spam], nil]];
}
- (IBAction)eventSeekForward:(id)sender
@ -514,6 +526,8 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
- (void)setPosition:(double)p
{
position = p;
[[playlistController currentEntry] setCurrentPosition:p];
}
- (double)position

View File

@ -18,6 +18,9 @@
"RepeatButtonTooltip" = "Repeat mode";
"FileButtonTooltip" = "File drawer";
"replayGainAlbumGain" = "The volume level of playback output will be detected through enumeration, \
re";
"InvalidURLShort" = "Invalid URL";
"InvalidURLLong" = "The URL is not valid.";

View File

@ -68,12 +68,12 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1913"/>
<binding destination="218" name="value" keyPath="arrangedObjects.index" id="1356">
<dictionary key="options">
<integer key="NSConditionallySetsEditable" value="1"/>
</dictionary>
</binding>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1913"/>
</connections>
</tableColumn>
<tableColumn identifier="status" editable="NO" width="20" minWidth="20" maxWidth="20" id="1798">
@ -82,7 +82,7 @@
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<imageCell key="dataCell" controlSize="small" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="E59717AB-CA52-4004-BC9D-131D5E3B8DF4" id="1801">
<imageCell key="dataCell" controlSize="small" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="F80A8C12-27F0-4575-9C0A-CE9017032213" id="1801">
<font key="font" metaFont="system"/>
</imageCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
@ -109,12 +109,12 @@
<sortDescriptor key="sortDescriptorPrototype" selector="caseInsensitiveCompare:" sortKey="title"/>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1914"/>
<binding destination="218" name="value" keyPath="arrangedObjects.title" id="814">
<dictionary key="options">
<integer key="NSConditionallySetsEditable" value="1"/>
</dictionary>
</binding>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1914"/>
</connections>
</tableColumn>
<tableColumn identifier="artist" editable="NO" width="90" minWidth="36" maxWidth="1000" id="391">
@ -131,12 +131,12 @@
<sortDescriptor key="sortDescriptorPrototype" selector="caseInsensitiveCompare:" sortKey="artist"/>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1916"/>
<binding destination="218" name="value" keyPath="arrangedObjects.artist" id="815">
<dictionary key="options">
<integer key="NSConditionallySetsEditable" value="1"/>
</dictionary>
</binding>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1916"/>
</connections>
</tableColumn>
<tableColumn identifier="album" editable="NO" width="97" minWidth="39" maxWidth="1000" id="806">
@ -153,12 +153,12 @@
<sortDescriptor key="sortDescriptorPrototype" selector="caseInsensitiveCompare:" sortKey="album"/>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1917"/>
<binding destination="218" name="value" keyPath="arrangedObjects.album" id="816">
<dictionary key="options">
<integer key="NSConditionallySetsEditable" value="1"/>
</dictionary>
</binding>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1917"/>
</connections>
</tableColumn>
<tableColumn identifier="length" editable="NO" width="105.62009999999999" minWidth="40.62012" maxWidth="1000" id="807">
@ -174,12 +174,12 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1919"/>
<binding destination="218" name="value" keyPath="arrangedObjects.length" id="1658">
<dictionary key="options">
<integer key="NSConditionallySetsEditable" value="1"/>
</dictionary>
</binding>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1919"/>
</connections>
</tableColumn>
<tableColumn identifier="year" editable="NO" width="77" minWidth="10" maxWidth="1000" id="848">
@ -195,8 +195,8 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1921"/>
<binding destination="218" name="value" keyPath="arrangedObjects.year" id="851"/>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1921"/>
</connections>
</tableColumn>
<tableColumn identifier="genre" editable="NO" width="83" minWidth="10" maxWidth="1000" id="849">
@ -213,8 +213,8 @@
<sortDescriptor key="sortDescriptorPrototype" selector="caseInsensitiveCompare:" sortKey="genre"/>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1922"/>
<binding destination="218" name="value" keyPath="arrangedObjects.genre" id="852"/>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1922"/>
</connections>
</tableColumn>
<tableColumn identifier="track" editable="NO" width="74" minWidth="4" maxWidth="1000" id="850">
@ -230,8 +230,8 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1923"/>
<binding destination="218" name="value" keyPath="arrangedObjects.track" id="853"/>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1923"/>
</connections>
</tableColumn>
<tableColumn identifier="path" editable="NO" width="57" minWidth="10" maxWidth="3.4028229999999999e+38" hidden="YES" id="1712">
@ -247,12 +247,12 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1924"/>
<binding destination="218" name="value" keyPath="arrangedObjects.path" id="1788">
<dictionary key="options">
<integer key="NSConditionallySetsEditable" value="1"/>
</dictionary>
</binding>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1924"/>
</connections>
</tableColumn>
<tableColumn identifier="filename" editable="NO" width="57" minWidth="10" maxWidth="3.4028229999999999e+38" hidden="YES" id="1736">
@ -268,12 +268,12 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<connections>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1925"/>
<binding destination="218" name="value" keyPath="arrangedObjects.filename" id="1787">
<dictionary key="options">
<integer key="NSConditionallySetsEditable" value="1"/>
</dictionary>
</binding>
<binding destination="1689" name="fontSize" keyPath="values.fontSize" id="1925"/>
</connections>
</tableColumn>
</tableColumns>
@ -333,6 +333,12 @@
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<connections>
<binding destination="218" name="predicate" keyPath="filterPredicate" id="1576">
<dictionary key="options">
<string key="NSDisplayName">All</string>
<string key="NSPredicateFormat">(title contains[cd] $value) OR (artist contains[cd] $value) OR (album contains[cd] $value) OR (genre contains[cd] $value)</string>
</dictionary>
</binding>
<binding destination="218" name="predicate2" keyPath="filterPredicate" previousBinding="1576" id="1578">
<dictionary key="options">
<string key="NSDisplayName">Title</string>
@ -347,26 +353,20 @@
</binding>
<binding destination="218" name="predicate4" keyPath="filterPredicate" previousBinding="1580" id="1582">
<dictionary key="options">
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
<integer key="NSValidatesImmediately" value="0"/>
<string key="NSPredicateFormat">artist contains[cd] $value</string>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<string key="NSPredicateFormat">artist contains[cd] $value</string>
<string key="NSDisplayName">Album</string>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
</dictionary>
</binding>
<binding destination="218" name="predicate5" keyPath="filterPredicate" previousBinding="1582" id="1583">
<dictionary key="options">
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
<integer key="NSValidatesImmediately" value="0"/>
<string key="NSPredicateFormat">genre contains[cd] $value</string>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<string key="NSPredicateFormat">genre contains[cd] $value</string>
<string key="NSDisplayName">Genre</string>
</dictionary>
</binding>
<binding destination="218" name="predicate" keyPath="filterPredicate" id="1576">
<dictionary key="options">
<string key="NSDisplayName">All</string>
<string key="NSPredicateFormat">(title contains[cd] $value) OR (artist contains[cd] $value) OR (album contains[cd] $value) OR (genre contains[cd] $value)</string>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
</dictionary>
</binding>
</connections>
@ -383,7 +383,7 @@
<segmentedCell key="cell" state="on" alignment="left" style="automatic" trackingMode="momentary" id="1538">
<font key="font" metaFont="system"/>
<segments>
<segment toolTip="Previous" image="previous" width="24"/>
<segment toolTip="Previous" image="previous" width="24" selected="YES"/>
<segment toolTip="Play" image="play" width="24" tag="1"/>
<segment toolTip="Next" image="next" width="24"/>
</segments>
@ -408,13 +408,13 @@
</sliderCell>
<connections>
<action selector="seek:" target="705" id="1597"/>
<binding destination="705" name="enabled" keyPath="seekable" id="2376"/>
<binding destination="1897" name="maxValue" keyPath="content.length" id="2377">
<dictionary key="options">
<bool key="NSRaisesForNotApplicableKeys" value="NO"/>
</dictionary>
</binding>
<binding destination="705" name="value" keyPath="position" previousBinding="2377" id="2378"/>
<binding destination="705" name="enabled" keyPath="seekable" id="2376"/>
<outlet property="positionTextField" destination="1566" id="2385"/>
</connections>
</slider>
@ -572,14 +572,14 @@
<toolbarItem implicitItemIdentifier="6F5A6C43-A09C-462A-AEE2-C86DC3C55128" label="Playback Buttons" paletteLabel="Playback Buttons" id="2272">
<nil key="toolTip"/>
<size key="minSize" width="80" height="24"/>
<size key="maxSize" width="80" height="24"/>
<size key="maxSize" width="80" height="25"/>
<segmentedControl key="view" verticalHuggingPriority="750" id="2295" customClass="PlaybackButtons">
<rect key="frame" x="9" y="14" width="80" height="24"/>
<rect key="frame" x="9" y="14" width="80" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<segmentedCell key="cell" state="on" alignment="left" style="automatic" trackingMode="momentary" id="2296">
<font key="font" metaFont="system"/>
<segments>
<segment toolTip="Previous" image="previous" width="24"/>
<segment toolTip="Previous" image="previous" width="24" selected="YES"/>
<segment toolTip="Play" image="play" width="24" tag="1"/>
<segment toolTip="Next" image="next" width="24"/>
</segments>
@ -601,9 +601,9 @@
</sliderCell>
<connections>
<action selector="seek:" target="705" id="2387"/>
<binding destination="705" name="enabled" keyPath="seekable" id="2384"/>
<binding destination="1897" name="maxValue" keyPath="content.length" id="2381"/>
<binding destination="705" name="value" keyPath="position" previousBinding="2381" id="2382"/>
<binding destination="705" name="enabled" keyPath="seekable" id="2384"/>
<outlet property="positionTextField" destination="2291" id="2386"/>
</connections>
</slider>
@ -685,7 +685,7 @@
<size key="minSize" width="24" height="25"/>
<size key="maxSize" width="24" height="25"/>
<button key="view" verticalHuggingPriority="750" id="2430">
<rect key="frame" x="23" y="14" width="24" height="25"/>
<rect key="frame" x="29" y="14" width="24" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="info_off" imagePosition="only" alignment="center" borderStyle="border" id="2431">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -1042,8 +1042,8 @@
<string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
</dictionary>
</binding>
</connections>
@ -1093,8 +1093,8 @@ CA
<string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="1"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="1"/>
</dictionary>
</binding>
</connections>
@ -1128,13 +1128,13 @@ CA
<connections>
<binding destination="218" name="value" keyPath="repeat" id="1760">
<dictionary key="options">
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSConditionallySetsEnabled" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
<string key="NSValueTransformerName">RepeatAllTransformer</string>
<integer key="NSConditionallySetsHidden" value="0"/>
<integer key="NSValidatesImmediately" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
</dictionary>
</binding>
</connections>
@ -1154,13 +1154,13 @@ CA
<connections>
<binding destination="218" name="value" keyPath="repeat" id="1763">
<dictionary key="options">
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSConditionallySetsEnabled" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
<string key="NSValueTransformerName">RepeatOneTransformer</string>
<integer key="NSConditionallySetsHidden" value="0"/>
<integer key="NSValidatesImmediately" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
</dictionary>
</binding>
</connections>
@ -1172,13 +1172,13 @@ CA
<connections>
<binding destination="218" name="value" keyPath="repeat" id="1767">
<dictionary key="options">
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSConditionallySetsEnabled" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
<integer key="NSAlwaysPresentsApplicationModalAlerts" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
<string key="NSValueTransformerName">RepeatNoneTransformer</string>
<integer key="NSConditionallySetsHidden" value="0"/>
<integer key="NSValidatesImmediately" value="0"/>
<integer key="NSAllowsEditingMultipleValuesSelection" value="0"/>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
</dictionary>
</binding>
</connections>
@ -1386,11 +1386,11 @@ Gw
<connections>
<binding destination="1897" name="title" keyPath="content.artist" id="2085">
<dictionary key="options">
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
<string key="NSMultipleValuesPlaceholder"></string>
<string key="NSNotApplicablePlaceholder"></string>
<string key="NSNoSelectionPlaceholder"></string>
<string key="NSMultipleValuesPlaceholder"></string>
<string key="NSNullPlaceholder">Not Playing</string>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
</dictionary>
</binding>
</connections>
@ -1400,11 +1400,11 @@ Gw
<connections>
<binding destination="1897" name="title" keyPath="content.title" id="2083">
<dictionary key="options">
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
<string key="NSMultipleValuesPlaceholder"></string>
<string key="NSNotApplicablePlaceholder"></string>
<string key="NSNoSelectionPlaceholder"></string>
<string key="NSMultipleValuesPlaceholder"></string>
<string key="NSNullPlaceholder">Not Playing</string>
<integer key="NSRaisesForNotApplicableKeys" value="1"/>
</dictionary>
</binding>
</connections>
@ -1503,8 +1503,8 @@ Gw
<string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
</dictionary>
</binding>
</connections>
@ -1518,8 +1518,8 @@ Gw
<string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
</dictionary>
</binding>
</connections>
@ -1536,8 +1536,8 @@ Gw
<string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
</dictionary>
</binding>
</connections>
@ -1551,8 +1551,8 @@ Gw
<string key="NSValueTransformerName">NSIsNotNil</string>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<integer key="NSMultipleValuesPlaceholder" value="0"/>
</dictionary>
</binding>
</connections>
@ -1585,7 +1585,7 @@ Gw
<slider horizontalHuggingPriority="750" id="1612" customClass="VolumeSlider">
<rect key="frame" x="43" y="39" width="15" height="120"/>
<autoresizingMask key="autoresizingMask"/>
<sliderCell key="cell" controlSize="small" continuous="YES" alignment="left" maxValue="100" doubleValue="100" tickMarkPosition="right" sliderType="linear" id="1613">
<sliderCell key="cell" controlSize="small" continuous="YES" alignment="left" maxValue="100" doubleValue="100" tickMarkPosition="left" sliderType="linear" id="1613">
<font key="font" metaFont="smallSystem"/>
</sliderCell>
<connections>
@ -1642,7 +1642,7 @@ Gw
<customObject id="2434" customClass="FeedbackController"/>
</objects>
<resources>
<image name="E59717AB-CA52-4004-BC9D-131D5E3B8DF4" width="17" height="17">
<image name="F80A8C12-27F0-4575-9C0A-CE9017032213" width="17" height="17">
<mutableData key="keyedArchiveRepresentation">
YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QDwcI
ExQZHh8qKyw0NzpAQ1UkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5T

View File

@ -38,6 +38,8 @@
float replayGainTrackGain;
float replayGainTrackPeak;
float volume;
double currentPosition;
long long totalFrames;
int bitrate;
@ -58,12 +60,15 @@
+ (NSSet *)keyPathsForValuesAffectingFilename;
+ (NSSet *)keyPathsForValuesAffectingStatus;
+ (NSSet *)keyPathsForValuesAffectingStatusMessage;
+ (NSSet *)keyPathsForValuesAffectingSpam;
@property(readonly) NSString *display;
@property(retain, readonly) NSNumber *length;
@property(readonly) NSString *path;
@property(readonly) NSString *filename;
@property(readonly) NSString *spam;
@property int index;
@property int shuffleIndex;
@ -103,6 +108,8 @@
@property float replayGainTrackPeak;
@property float volume;
@property double currentPosition;
@property(retain) NSString *endian;
@property BOOL seekable;

View File

@ -7,6 +7,7 @@
//
#import "PlaylistEntry.h"
#import "SecondsFormatter.h"
@implementation PlaylistEntry
@ -45,6 +46,8 @@
@synthesize replayGainTrackPeak;
@synthesize volume;
@synthesize currentPosition;
@synthesize endian;
@synthesize seekable;
@ -83,6 +86,11 @@
return [NSSet setWithObjects:@"current", @"queued", @"queuePosition", @"error", @"errorMessage", @"stopAfter", nil];
}
+ (NSSet *)keyPathsForValuesAffectingSpam
{
return [NSSet setWithObjects:@"artist", @"title", @"album", @"track", @"totalFrames", @"currentPosition", @"bitrate", nil];
}
- (NSString *)description
{
return [NSString stringWithFormat:@"PlaylistEntry %i:(%@)", self.index, self.URL];
@ -140,6 +148,86 @@
}
}
@dynamic spam;
- (NSString *)spam
{
BOOL hasBitrate = (self.bitrate != 0);
BOOL hasArtist = (self.artist != nil) && (![self.artist isEqualToString:@""]);
BOOL hasAlbum = (self.album != nil) && (![self.album isEqualToString:@""]);
BOOL hasTrack = (self.track != 0);
BOOL hasLength = (self.totalFrames != 0);
BOOL hasCurrentPosition = (self.currentPosition != 0) && (self.current);
BOOL hasExtension = NO;
BOOL hasTitle = (title != nil) && (![title isEqualToString:@""]);
NSMutableString * filename = [NSMutableString stringWithString:[self filename]];
NSRange dotPosition = [filename rangeOfString:@"." options:NSBackwardsSearch];
NSString * extension = nil;
if (dotPosition.length > 0) {
dotPosition.location++;
dotPosition.length = [filename length] - dotPosition.location;
extension = [filename substringWithRange:dotPosition];
dotPosition.location--;
dotPosition.length++;
[filename deleteCharactersInRange:dotPosition];
hasExtension = YES;
}
NSMutableArray * elements = [NSMutableArray array];
if (hasExtension) {
[elements addObject:@"["];
[elements addObject:[extension uppercaseString]];
if (hasBitrate) {
[elements addObject:@"@"];
[elements addObject:[NSString stringWithFormat:@"%u", self.bitrate / 1000]];
[elements addObject:@"kbps"];
}
[elements addObject:@"] "];
}
if (hasArtist) {
[elements addObject:self.artist];
[elements addObject:@" - "];
}
if (hasAlbum) {
[elements addObject:@"["];
[elements addObject:self.album];
if (hasTrack) {
[elements addObject:@" #"];
[elements addObject:[NSString stringWithFormat:@"%@", self.track]];
}
[elements addObject:@"] "];
}
if (hasTitle) {
[elements addObject:title];
}
else {
[elements addObject:filename];
}
if (hasCurrentPosition || hasLength) {
SecondsFormatter *secondsFormatter = [[SecondsFormatter alloc] init];
[elements addObject:@" ("];
if (hasCurrentPosition) {
[elements addObject:[secondsFormatter stringForObjectValue:[NSNumber numberWithFloat:currentPosition]]];
}
if (hasLength) {
if (hasCurrentPosition) {
[elements addObject:@" / "];
}
[elements addObject:[secondsFormatter stringForObjectValue:[self length]]];
}
[elements addObject:@")"];
[secondsFormatter release];
}
return [elements componentsJoinedByString:@""];
}
@dynamic length;
- (NSNumber *)length
{

View File

@ -22,15 +22,16 @@
<outlet property="nextHotKeyControl" destination="28" id="36"/>
<outlet property="playHotKeyControl" destination="16" id="34"/>
<outlet property="prevHotKeyControl" destination="27" id="35"/>
<outlet property="spamHotKeyControl" destination="2Eh-AY-mzV" id="B2t-Ar-T97"/>
<outlet property="view" destination="11" id="12"/>
</connections>
</customObject>
<customView id="11" userLabel="HotKeyView">
<rect key="frame" x="0.0" y="0.0" width="432" height="109"/>
<rect key="frame" x="0.0" y="0.0" width="432" height="131"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" id="30">
<rect key="frame" x="175" y="12" width="64" height="32"/>
<rect key="frame" x="175" y="34" width="64" height="32"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="push" title="Edit" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="204">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -40,8 +41,19 @@
<action selector="grabNextHotKey:" target="6" id="33"/>
</connections>
</button>
<button verticalHuggingPriority="750" id="KcI-9g-270">
<rect key="frame" x="175" y="9" width="64" height="32"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="push" title="Edit" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="6zz-ME-x1V">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="grabSpamHotKey:" target="6" id="wyh-q1-p3g"/>
</connections>
</button>
<button verticalHuggingPriority="750" id="29">
<rect key="frame" x="175" y="37" width="64" height="32"/>
<rect key="frame" x="175" y="59" width="64" height="32"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="push" title="Edit" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="203">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -52,7 +64,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" id="28" customClass="HotKeyControl">
<rect key="frame" x="91" y="20" width="82" height="19"/>
<rect key="frame" x="91" y="42" width="82" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="202">
<font key="font" metaFont="smallSystem"/>
@ -63,8 +75,20 @@
<action selector="hotKeyChanged:" target="6" id="38"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" id="2Eh-AY-mzV" customClass="HotKeyControl">
<rect key="frame" x="91" y="17" width="82" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="A8w-Tx-TAd">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="hotKeyChanged:" target="6" id="WrA-Jp-1SV"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" id="27" customClass="HotKeyControl">
<rect key="frame" x="91" y="45" width="82" height="19"/>
<rect key="frame" x="91" y="67" width="82" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="201">
<font key="font" metaFont="smallSystem"/>
@ -76,34 +100,34 @@
</connections>
</textField>
<textField verticalHuggingPriority="750" id="26">
<rect key="frame" x="40" y="22" width="44" height="17"/>
<rect key="frame" x="42" y="44" width="44" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Next:" id="200">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Next:" id="200">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" id="25">
<rect key="frame" x="17" y="47" width="69" height="17"/>
<rect key="frame" x="17" y="69" width="69" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Previous:" id="199">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Previous:" id="199">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" id="24">
<rect key="frame" x="45" y="72" width="39" height="17"/>
<rect key="frame" x="47" y="94" width="39" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Play:" id="198">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Play:" id="198">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" id="17">
<rect key="frame" x="175" y="62" width="64" height="32"/>
<rect key="frame" x="175" y="84" width="64" height="32"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="push" title="Edit" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="197">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -115,7 +139,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" id="16" customClass="HotKeyControl">
<rect key="frame" x="91" y="70" width="82" height="19"/>
<rect key="frame" x="91" y="92" width="82" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="196">
<font key="font" metaFont="smallSystem"/>
@ -127,6 +151,15 @@
<outlet property="nextKeyView" destination="17" id="22"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="eid-M4-6Cs">
<rect key="frame" x="24" y="19" width="62" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Spam:" id="SMd-GA-jrH">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</customView>
<customView id="43" userLabel="RemoteView">

View File

@ -14,11 +14,13 @@
IBOutlet HotKeyControl *playHotKeyControl;
IBOutlet HotKeyControl *prevHotKeyControl;
IBOutlet HotKeyControl *nextHotKeyControl;
IBOutlet HotKeyControl *spamHotKeyControl;
}
- (IBAction) grabPlayHotKey:(id)sender;
- (IBAction) grabPrevHotKey:(id)sender;
- (IBAction) grabNextHotKey:(id)sender;
- (IBAction) grabSpamHotKey:(id)sender;
- (IBAction) hotKeyChanged:(id)sender;

View File

@ -33,6 +33,12 @@
[playHotKeyControl setModifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPlayModifiers"] ];
[playHotKeyControl updateStringValue];
[spamHotKeyControl setKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamKeyCode"] ];
[spamHotKeyControl setCharacter: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamCharacter"] ];
[spamHotKeyControl setModifierFlags: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamModifiers"] ];
[spamHotKeyControl updateStringValue];
}
- (NSString *)title
@ -60,6 +66,7 @@
[playHotKeyControl stopObserving];
[prevHotKeyControl stopObserving];
[nextHotKeyControl stopObserving];
[spamHotKeyControl stopObserving];
}
}
@ -78,6 +85,11 @@
[nextHotKeyControl startObserving];
}
- (IBAction) grabSpamHotKey:(id)sender
{
[spamHotKeyControl startObserving];
}
- (IBAction) hotKeyChanged:(id)sender
{
if (sender == playHotKeyControl) {
@ -95,6 +107,11 @@
[[NSUserDefaults standardUserDefaults] setInteger:[nextHotKeyControl modifierFlags] forKey:@"hotKeyNextModifiers"];
[[NSUserDefaults standardUserDefaults] setInteger:[nextHotKeyControl keyCode] forKey:@"hotKeyNextKeyCode"];
}
else if (sender == spamHotKeyControl) {
[[NSUserDefaults standardUserDefaults] setInteger:[spamHotKeyControl character] forKey:@"hotKeySpamCharacter"];
[[NSUserDefaults standardUserDefaults] setInteger:[spamHotKeyControl modifierFlags] forKey:@"hotKeySpamModifiers"];
[[NSUserDefaults standardUserDefaults] setInteger:[spamHotKeyControl keyCode] forKey:@"hotKeySpamKeyCode"];
}
[sender stopObserving];
}