From fce120b94a1adc6b9c6e1796217d8065bc105fbb Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Wed, 7 Sep 2005 20:31:59 +0000 Subject: [PATCH] Fixed problems with iTunes 5 and repeat mode. Made it so shuffle and loop work on the currently selected playlist if there is no active playlist. --- English.lproj/Localizable.strings | 2 +- iTunesRemote.m | 33 ++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/English.lproj/Localizable.strings b/English.lproj/Localizable.strings index 665f569..67011b8 100755 --- a/English.lproj/Localizable.strings +++ b/English.lproj/Localizable.strings @@ -29,7 +29,7 @@ playCount = "Play Count"; shuffleOn = "Shuffle On"; shuffleOff = "Shuffle Off"; repeatOff = "Repeat Off"; -repeatPlaying = "Repeat Playlist"; +repeatPlaylist = "Repeat Playlist"; repeatOneTrack = "Repeat One Track"; noSongPlaying = "No song is playing."; iTunesNotResponding = "iTunes is not responding."; diff --git a/iTunesRemote.m b/iTunesRemote.m index 5fb5233..35768cd 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -630,8 +630,14 @@ - (BOOL)shuffleEnabled { + int result; ITDebugLog(@"Getting shuffle enabled status."); - int result = (int)[ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value]; + if ([[self playerStateUniqueIdentifier] isEqualToString:@"0-0"]) { + ITDebugLog(@"No current playlist, getting shuffle status from visible playlist."); + result = (int)[ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPly'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } } }", 'core', 'getd', &savedPSN) int32Value]; + } else { + result = (int)[ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value]; + } ITDebugLog(@"Getting shuffle enabled status done."); return (result != 0); } @@ -639,7 +645,12 @@ - (BOOL)setShuffleEnabled:(BOOL)enabled { ITDebugLog(@"Set shuffle enabled to %i", enabled); - ITSendAEWithString([NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }", (unsigned long)enabled], 'core', 'setd', &savedPSN); + if ([[self playerStateUniqueIdentifier] isEqualToString:@"0-0"]) { + ITDebugLog(@"No current playlist, setting shuffle status on visible playlist."); + ITSendAEWithString([NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPly'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } } }", (unsigned long)enabled], 'core', 'setd', &savedPSN); + } else { + ITSendAEWithString([NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }", (unsigned long)enabled], 'core', 'setd', &savedPSN); + } ITDebugLog(@"Set shuffle enabled to %i done", enabled); return YES; } @@ -648,8 +659,14 @@ { FourCharCode m00f = 0; int result = 0; - m00f = (FourCharCode)[ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pRpt'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value]; - ITDebugLog(@"Getting repeat mode."); + ITDebugLog(@"Getting repeat mode."); + m00f = (FourCharCode)[ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pRpt'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }", 'core', 'getd', &savedPSN) typeCodeValue]; + + if (m00f == 0) { + ITDebugLog(@"No current playlist, getting repeat mode from visible playlist."); + m00f = (FourCharCode)[ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pRpt'), from:obj { form:'prop', want:type('prop'), seld:type('pPly'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } } }", 'core', 'getd', &savedPSN) typeCodeValue]; + } + switch (m00f) { //case 'kRp0': @@ -687,7 +704,12 @@ m00f = "kRp0"; break; } - ITSendAEWithString([NSString stringWithFormat:@"data:'%s', '----':obj { form:'prop', want:type('prop'), seld:type('pRpt'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:() } }", m00f], 'core', 'setd', &savedPSN); + if ([[self playerStateUniqueIdentifier] isEqualToString:@"0-0"]) { + ITDebugLog(@"No current playlist, setting repeat mode on visible playlist."); + ITSendAEWithString([NSString stringWithFormat:@"data:'%s', '----':obj { form:'prop', want:type('prop'), seld:type('pRpt'), from:obj { form:'prop', want:type('prop'), seld:type('pPly'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } } }", m00f], 'core', 'setd', &savedPSN); + } else { + ITSendAEWithString([NSString stringWithFormat:@"data:'%s', '----':obj { form:'prop', want:type('prop'), seld:type('pRpt'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:() } }", m00f], 'core', 'setd', &savedPSN); + } ITDebugLog(@"Setting repeat mode to %c done", m00f); return YES; } @@ -802,6 +824,7 @@ //Duplicate search results to playlist for (i = 1; i <= [searchResults numberOfItems]; i++) { //NSLog(@"%@", ITSendAEWithStringAndParameter(@"'----':obj { form:'prop', want:type('prop'), seld:prop('pnam'), from:aevt(@) }", *[[searchResults descriptorAtIndex:i] aeDesc], 'core', 'getd', &savedPSN)); + ITSendAEWithStringAndObject(@"insh:obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:'null'() }", [[searchResults descriptorAtIndex:i] aeDesc], 'core', 'clon', &savedPSN); } //Reset fixed indexing -- 2.20.1