X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/0b727e3ec3a58f5751bb8f41079162c1c4c09e2d..865ed626fce033da225a4a93646ad185f72c74ff:/iTunesRemote.m diff --git a/iTunesRemote.m b/iTunesRemote.m index 34d49bd..0689704 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -168,6 +168,7 @@ ITDebugLog(@"Getting playlists."); if (numSources == 0) { + [allSources release]; ITDebugLog(@"No sources."); return nil; } @@ -271,8 +272,10 @@ makePlaylistWithTerm:ofType: method. */ int temp1; + NSAppleEventDescriptor *result; ITDebugLog(@"Getting number of songs in playlist at index %i", index); - temp1 = (int)[ITSendAEWithString([NSString stringWithFormat:@"kocl:type('cTrk'), '----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", index], 'core', 'cnte', &savedPSN) int32Value]; + result = ITSendAEWithString([NSString stringWithFormat:@"kocl:type('cTrk'), '----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", index], 'core', 'cnte', &savedPSN); + temp1 = (result == nil) ? -1 : (int)[result int32Value]; ITDebugLog(@"Getting number of songs in playlist at index %i done", index); return temp1; } @@ -385,8 +388,8 @@ NSString *temp1; ITDebugLog(@"Getting current unique identifier."); NSAppleEventDescriptor *descriptor = ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN); - if (descriptor == nil) { - return nil; + if ((descriptor == nil) || ([descriptor int32Value] == 'prop')) { + return @"0-0"; } SInt32 cls = [descriptor int32Value]; if ( ([self currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist) || (cls == 'cURT') ) { @@ -406,7 +409,7 @@ { int temp1; ITDebugLog(@"Getting current song index."); - temp1 = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pidx'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value]; + temp1 = (([ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value] != 'prop') ? [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pidx'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value] : -1); ITDebugLog(@"Getting current song index done."); return temp1; }