sharedController = self;
remoteArray = [[NSMutableArray alloc] initWithCapacity:1];
- statusWindowController = [[StatusWindowController alloc] init];
+ statusWindowController = [StatusWindowController sharedController];
menuController = [[MenuController alloc] init];
df = [[NSUserDefaults standardUserDefaults] retain];
+ timerUpdating = NO;
}
return self;
}
SetITDebugMode(YES);
}
+ bling = [[MTBlingController alloc] init];
+ blingDate = nil;
+
currentRemote = [self loadRemote];
[currentRemote begin];
[statusItem setImage:[NSImage imageNamed:@"MenuNormal"]];
[statusItem setAlternateImage:[NSImage imageNamed:@"MenuInverted"]];
+
+ [NSApp deactivate];
}
- (ITMTRemote *)loadRemote
[pool release];
}*/
+- (void)blingTime
+{
+ NSDate *now = [NSDate date];
+ if ( (! blingDate) || ([now timeIntervalSinceDate:blingDate] >= 86400) ) {
+ [bling showPanelIfNeeded];
+ [blingDate autorelease];
+ blingDate = [now retain];
+ }
+}
+
+- (void)blingNow
+{
+ [bling showPanel];
+ [blingDate autorelease];
+ blingDate = [[NSDate date] retain];
+}
+
+- (BOOL)blingBling
+{
+ if ( ! ([bling checkDone] == 2475) ) {
+ return NO;
+ } else {
+ return YES;
+ }
+}
+
- (BOOL)songIsPlaying
{
return ( ! ([[currentRemote playerStateUniqueIdentifier] isEqualToString:@"0-0"]) );
- (void)timerUpdate
{
- if ( [self songChanged] ) {
+ if ( [self songChanged] && (timerUpdating != YES) ) {
ITDebugLog(@"The song changed.");
- [self setLatestSongIdentifier:[currentRemote playerStateUniqueIdentifier]];
+ timerUpdating = YES;
latestPlaylistClass = [currentRemote currentPlaylistClass];
[menuController rebuildSubmenus];
if ( [df boolForKey:@"showSongInfoOnChange"] ) {
-// [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
+ [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
}
+
+ [self setLatestSongIdentifier:[currentRemote playerStateUniqueIdentifier]];
+
+ timerUpdating = NO;
}
}
{
ITHotKey *hotKey;
ITDebugLog(@"Setting up hot keys.");
+
+ if (playerRunningState == ITMTRemotePlayerNotRunning) {
+ return;
+ }
+
if ([df objectForKey:@"PlayPause"] != nil) {
ITDebugLog(@"Setting up play pause hot key.");
hotKey = [[ITHotKey alloc] init];
NSString *album = nil;
NSString *artist = nil;
NSString *time = nil;
- int trackNumber = 0;
- int trackTotal = 0;
+ NSString *track = nil;
int rating = -1;
+
ITDebugLog(@"Showing track info status window.");
+
if ( title ) {
if ( [df boolForKey:@"showAlbum"] ) {
}
if ( [df boolForKey:@"showTime"] ) {
- time = [currentRemote currentSongLength];
+ time = [NSString stringWithFormat:@"%@: %@ / %@",
+ @"Time",
+ [currentRemote currentSongElapsed],
+ [currentRemote currentSongLength]];
}
- if ( [df boolForKey:@"showNumber"] ) {
- trackNumber = [currentRemote currentSongTrack];
- trackTotal = [currentRemote currentAlbumTrackCount];
+ if ( [df boolForKey:@"showTrackNumber"] ) {
+ int trackNo = [currentRemote currentSongTrack];
+ int trackCount = [currentRemote currentAlbumTrackCount];
+
+ if ( (trackNo > 0) || (trackCount > 0) ) {
+ track = [NSString stringWithFormat:@"%@: %i %@ %i",
+ @"Track", trackNo, @"of", trackCount];
+ }
}
- if ( [df boolForKey:@"showRating"] ) {
- rating = ( [currentRemote currentSongRating] * 5 );
+ if ( [df boolForKey:@"showTrackRating"] ) {
+ float currentRating = [currentRemote currentSongRating];
+ if (currentRating >= 0.0) {
+ rating = ( currentRating * 5 );
+ }
}
} else {
album:album
artist:artist
time:time
- trackNumber:trackNumber
- trackTotal:trackTotal
+ track:track
rating:rating];
}
{
float rating = [currentRemote currentSongRating];
ITDebugLog(@"Incrementing rating.");
+
+ if ([currentRemote currentPlaylistIndex] == 0) {
+ ITDebugLog(@"No song playing, rating change aborted.");
+ return;
+ }
+
rating += 0.2;
if (rating > 1.0) {
rating = 1.0;
{
float rating = [currentRemote currentSongRating];
ITDebugLog(@"Decrementing rating.");
+
+ if ([currentRemote currentPlaylistIndex] == 0) {
+ ITDebugLog(@"No song playing, rating change aborted.");
+ return;
+ }
+
rating -= 0.2;
if (rating < 0.0) {
rating = 0.0;
- (void)toggleShuffle
{
- bool newShuffleEnabled = ![currentRemote shuffleEnabled];
+ BOOL newShuffleEnabled = ( ! [currentRemote shuffleEnabled] );
ITDebugLog(@"Toggling shuffle mode.");
[currentRemote setShuffleEnabled:newShuffleEnabled];
//Show shuffle status window
ITDebugLog(@"Setting shuffle mode to %i", newShuffleEnabled);
- [statusWindowController showRepeatWindowWithMode:newShuffleEnabled];
+ [statusWindowController showShuffleWindow:newShuffleEnabled];
}
/*************************************************************************/
- (void)dealloc
{
[self applicationTerminated:nil];
+ [bling release];
[statusItem release];
[statusWindowController release];
[menuController release];