{
ITDebugLog(@"Selecting playlist %i", index);
NS_DURING
- [[self currentRemote] switchToPlaylistAtIndex:index];
+ [[self currentRemote] switchToPlaylistAtIndex:(index / 1000) ofSourceAtIndex:(index % 1000)];
NS_HANDLER
[self networkError:localException];
NS_ENDHANDLER
- (ITMTRemote *)currentRemote
{
+ if ([networkController isConnectedToServer] && ![[networkController networkObject] isValid]) {
+ [self networkError:nil];
+ return nil;
+ }
return currentRemote;
}
if ([networkController checkForServerAtHost:[df stringForKey:@"sharedPlayerHost"]]) {
ITDebugLog(@"Remote server found.");
[timer invalidate];
- if (![networkController isConnectedToServer]) {
+ if (![networkController isServerOn] && ![networkController isConnectedToServer]) {
[[StatusWindowController sharedController] showReconnectQueryWindow];
}
} else {
- (void)networkError:(NSException *)exception
{
ITDebugLog(@"Remote exception thrown: %@: %@", [exception name], [exception reason]);
- NSLog(@"%@", [exception reason]);
- if ([[exception name] isEqualToString:NSPortTimeoutException] && [networkController isConnectedToServer]) {
+ if ( ((exception == nil) || [[exception name] isEqualToString:NSPortTimeoutException]) && [networkController isConnectedToServer]) {
NSRunCriticalAlertPanel(@"Remote MenuTunes Disconnected", @"The MenuTunes server you were connected to stopped responding or quit. MenuTunes will revert back to the local player.", @"OK", nil, nil);
if ([self disconnectFromServer]) {
[[PreferencesController sharedPrefs] resetRemotePlayerTextFields];