git.ithinksw.org
/
MenuTunes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed audioscrobbler track timings to be correct
[MenuTunes.git]
/
MainController.m
diff --git
a/MainController.m
b/MainController.m
index
4994a7d
..
14bfb59
100755
(executable)
--- a/
MainController.m
+++ b/
MainController.m
@@
-140,6
+140,8
@@
static MainController *sharedController;
currentRemote = [self loadRemote];
[[self currentRemote] begin];
currentRemote = [self loadRemote];
[[self currentRemote] begin];
+ [[self currentRemote] currentSongElapsed];
+
//Turn on network stuff if needed
networkController = [[NetworkController alloc] init];
if ([df boolForKey:@"enableSharing"]) {
//Turn on network stuff if needed
networkController = [[NetworkController alloc] init];
if ([df boolForKey:@"enableSharing"]) {
@@
-410,7
+412,12
@@
static MainController *sharedController;
- (void)timerUpdate
{
- (void)timerUpdate
{
- NSString *identifier = [[self currentRemote] playerStateUniqueIdentifier];
+ NSString *identifier = nil;
+ NS_DURING
+ identifier = [[self currentRemote] playerStateUniqueIdentifier];
+ NS_HANDLER
+ [self networkError:localException];
+ NS_ENDHANDLER
if (refreshTimer && identifier == nil) {
if ([statusItem isEnabled]) {
[statusItem setToolTip:@"iTunes not responding."];
if (refreshTimer && identifier == nil) {
if ([statusItem isEnabled]) {
[statusItem setToolTip:@"iTunes not responding."];
@@
-476,7
+483,7
@@
static MainController *sharedController;
[_audioscrobblerTimer invalidate];
}
if (length > 30) {
[_audioscrobblerTimer invalidate];
}
if (length > 30) {
- _audioscrobblerTimer = [NSTimer scheduledTimerWithTimeInterval:((length
< 240) ? length / 2 : 12
0) target:self selector:@selector(submitAudioscrobblerTrack:) userInfo:nil repeats:YES];
+ _audioscrobblerTimer = [NSTimer scheduledTimerWithTimeInterval:((length
/ 2 < 240) ? length / 2 : 24
0) target:self selector:@selector(submitAudioscrobblerTrack:) userInfo:nil repeats:YES];
}
} else {
_audioscrobblerTimer = nil;
}
} else {
_audioscrobblerTimer = nil;
@@
-602,7
+609,7
@@
static MainController *sharedController;
[_audioscrobblerTimer invalidate];
}
if (length > 30) {
[_audioscrobblerTimer invalidate];
}
if (length > 30) {
- _audioscrobblerTimer = [NSTimer scheduledTimerWithTimeInterval:((length
< 240) ? length / 2 : 12
0) target:self selector:@selector(submitAudioscrobblerTrack:) userInfo:nil repeats:YES];
+ _audioscrobblerTimer = [NSTimer scheduledTimerWithTimeInterval:((length
/ 2 < 240) ? length / 2 : 24
0) target:self selector:@selector(submitAudioscrobblerTrack:) userInfo:nil repeats:YES];
}
} else {
_audioscrobblerTimer = nil;
}
} else {
_audioscrobblerTimer = nil;
@@
-1219,9
+1226,9
@@
static MainController *sharedController;
- (void)updateTime:(NSTimer *)timer
{
- (void)updateTime:(NSTimer *)timer
{
- StatusWindow *sw = [StatusWindow sharedWindow];
+ StatusWindow *sw =
(StatusWindow *)
[StatusWindow sharedWindow];
_timeUpdateCount++;
_timeUpdateCount++;
- if (
_timeUpdateCount < (int)[sw exitDelay] + (int)[[sw exitEffect] effectTime] + (int)[[sw entryEffect] effectTime]
) {
+ if (
[sw visibilityState] != ITWindowHiddenState
) {
NSString *time = nil, *length;
NS_DURING
length = [[self currentRemote] currentSongLength];
NSString *time = nil, *length;
NS_DURING
length = [[self currentRemote] currentSongLength];
@@
-1519,12
+1526,14
@@
static MainController *sharedController;
if (refreshTimer) {
[refreshTimer invalidate];
}
if (refreshTimer) {
[refreshTimer invalidate];
}
- refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
- target:self
- selector:@selector(timerUpdate)
- userInfo:nil
- repeats:YES] retain];
}
}
+
+ refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
+ target:self
+ selector:@selector(timerUpdate)
+ userInfo:nil
+ repeats:YES] retain];
+
[self timerUpdate];
ITDebugLog(@"Connection successful.");
return 1;
[self timerUpdate];
ITDebugLog(@"Connection successful.");
return 1;
@@
-1549,10
+1558,12
@@
static MainController *sharedController;
[networkController disconnect];
if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
[networkController disconnect];
if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
+ refreshTimer = nil;
[self applicationLaunched:nil];
} else {
[self applicationTerminated:nil];
}
[self applicationLaunched:nil];
} else {
[self applicationTerminated:nil];
}
+
if (refreshTimer) {
[self timerUpdate];
};
if (refreshTimer) {
[self timerUpdate];
};