Moved PlaylistEntry number variables over to NSNumber. Removed displayIndex and lengthString, using formatters instead. Fix bug with autosaving playlist.

CQTexperiment
vspader 2007-03-14 02:28:30 +00:00
parent 71577bac3d
commit 4ed575f475
15 changed files with 152 additions and 127 deletions

View File

@ -161,15 +161,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
{ {
NSURL *url = [NSURL URLWithString:[urlComboBox stringValue]]; NSURL *url = [NSURL URLWithString:[urlComboBox stringValue]];
PlaylistEntry *pe = [[PlaylistEntry alloc] init]; [playlistLoader addURLs:[NSArray arrayWithObject:url] sort:NO];
[pe setURL:url];
[pe setIndex:[[playlistController arrangedObjects] count]];
[pe setTitle:[urlComboBox stringValue]];
[playlistController addObject:pe];
[pe release];
[NSApp endSheet:addURLPanel]; [NSApp endSheet:addURLPanel];
[addURLPanel orderOut:self]; [addURLPanel orderOut:self];

View File

@ -5,10 +5,10 @@
#import <Growl/GrowlApplicationBridge.h> #import <Growl/GrowlApplicationBridge.h>
#import "CogAudio/AudioPlayer.h" #import "CogAudio/AudioPlayer.h"
#import "PlaylistController.h"
#import "TrackingSlider.h" #import "TrackingSlider.h"
#import "AudioScrobbler.h" #import "AudioScrobbler.h"
@class PlaylistController;
@class PlaylistView; @class PlaylistView;
@interface PlaybackController : NSObject <GrowlApplicationBridgeDelegate> @interface PlaybackController : NSObject <GrowlApplicationBridgeDelegate>

View File

@ -4,6 +4,9 @@
#import "DBLog.h" #import "DBLog.h"
#import "CogAudio/Status.h" #import "CogAudio/Status.h"
#import "PlaylistController.h"
#import "PlaylistEntry.h"
@implementation PlaybackController @implementation PlaybackController
- (id)init - (id)init
@ -289,11 +292,11 @@
if ([playlistController shuffle] == YES) if ([playlistController shuffle] == YES)
{ {
pe = [playlistController entryAtIndex:[curEntry shuffleIndex]+1]; pe = [playlistController entryAtIndex:[[curEntry shuffleIndex] intValue] + 1];
} }
else else
{ {
pe = [playlistController entryAtIndex:[curEntry index]+1]; pe = [playlistController entryAtIndex:[[curEntry index] intValue] + 1];
} }
if (pe == nil) if (pe == nil)

View File

@ -104,7 +104,7 @@ escapeForLastFM(NSString *string)
escapeForLastFM([pe title]), escapeForLastFM([pe title]),
escapeForLastFM([pe album]), escapeForLastFM([pe album]),
@"", // TODO: MusicBrainz support @"", // TODO: MusicBrainz support
(int)([pe length]/1000.0), (int)([[pe length] doubleValue]/1000.0),
escapeForLastFM([[pe url] path]) escapeForLastFM([[pe url] path])
]]; ]];
} }

View File

@ -100,6 +100,12 @@
8E7575D009F31DCA0080F1EE /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575C809F31DCA0080F1EE /* Credits.html */; }; 8E7575D009F31DCA0080F1EE /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575C809F31DCA0080F1EE /* Credits.html */; };
8E7575D109F31DCA0080F1EE /* README in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575C909F31DCA0080F1EE /* README */; }; 8E7575D109F31DCA0080F1EE /* README in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575C909F31DCA0080F1EE /* README */; };
8E7575DB09F31E930080F1EE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575D909F31E930080F1EE /* Localizable.strings */; }; 8E7575DB09F31E930080F1EE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575D909F31E930080F1EE /* Localizable.strings */; };
8E9A2E850BA78B500091081B /* SecondsFormatter.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E9A2E830BA78B500091081B /* SecondsFormatter.h */; };
8E9A2E860BA78B500091081B /* SecondsFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A2E840BA78B500091081B /* SecondsFormatter.m */; };
8E9A2ED90BA78D9D0091081B /* IndexFormatter.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E9A2ED70BA78D9D0091081B /* IndexFormatter.h */; };
8E9A2EDA0BA78D9D0091081B /* IndexFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */; };
8E9A30150BA792DC0091081B /* NSFileHandle+CreateFile.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E9A30130BA792DC0091081B /* NSFileHandle+CreateFile.h */; };
8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A30140BA792DC0091081B /* NSFileHandle+CreateFile.m */; };
8EFFCD5F0AA093AF00C458A5 /* DirectoryNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */; }; 8EFFCD5F0AA093AF00C458A5 /* DirectoryNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */; };
8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD450AA093AF00C458A5 /* FileIconCell.m */; }; 8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD450AA093AF00C458A5 /* FileIconCell.m */; };
8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD470AA093AF00C458A5 /* FileNode.m */; }; 8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD470AA093AF00C458A5 /* FileNode.m */; };
@ -141,6 +147,9 @@
170680840B950164006BA573 /* Growl.framework in CopyFiles */, 170680840B950164006BA573 /* Growl.framework in CopyFiles */,
17F94CCD0B8D090800A34E87 /* Sparkle.framework in CopyFiles */, 17F94CCD0B8D090800A34E87 /* Sparkle.framework in CopyFiles */,
1755E1F80BA0D2B600CA3560 /* PlaylistLoader.h in CopyFiles */, 1755E1F80BA0D2B600CA3560 /* PlaylistLoader.h in CopyFiles */,
8E9A2E850BA78B500091081B /* SecondsFormatter.h in CopyFiles */,
8E9A2ED90BA78D9D0091081B /* IndexFormatter.h in CopyFiles */,
8E9A30150BA792DC0091081B /* NSFileHandle+CreateFile.h in CopyFiles */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -277,6 +286,12 @@
8E7575C909F31DCA0080F1EE /* README */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = README; sourceTree = "<group>"; }; 8E7575C909F31DCA0080F1EE /* README */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
8E7575DA09F31E930080F1EE /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; }; 8E7575DA09F31E930080F1EE /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
8E7575DC09F31EAF0080F1EE /* French */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = French; path = French.lproj/Localizable.strings; sourceTree = "<group>"; }; 8E7575DC09F31EAF0080F1EE /* French */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = French; path = French.lproj/Localizable.strings; sourceTree = "<group>"; };
8E9A2E830BA78B500091081B /* SecondsFormatter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SecondsFormatter.h; sourceTree = "<group>"; };
8E9A2E840BA78B500091081B /* SecondsFormatter.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SecondsFormatter.m; sourceTree = "<group>"; };
8E9A2ED70BA78D9D0091081B /* IndexFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexFormatter.h; sourceTree = "<group>"; };
8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IndexFormatter.m; sourceTree = "<group>"; };
8E9A30130BA792DC0091081B /* NSFileHandle+CreateFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFileHandle+CreateFile.h"; sourceTree = "<group>"; };
8E9A30140BA792DC0091081B /* NSFileHandle+CreateFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSFileHandle+CreateFile.m"; sourceTree = "<group>"; };
8EFFCD420AA093AF00C458A5 /* DirectoryNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DirectoryNode.h; sourceTree = "<group>"; }; 8EFFCD420AA093AF00C458A5 /* DirectoryNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DirectoryNode.h; sourceTree = "<group>"; };
8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = DirectoryNode.m; sourceTree = "<group>"; }; 8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = DirectoryNode.m; sourceTree = "<group>"; };
8EFFCD440AA093AF00C458A5 /* FileIconCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileIconCell.h; sourceTree = "<group>"; }; 8EFFCD440AA093AF00C458A5 /* FileIconCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileIconCell.h; sourceTree = "<group>"; };
@ -470,6 +485,8 @@
177EC01B0B8BC2CF0000BC8C /* TrackingCell.m */, 177EC01B0B8BC2CF0000BC8C /* TrackingCell.m */,
177EC01C0B8BC2CF0000BC8C /* TrackingSlider.h */, 177EC01C0B8BC2CF0000BC8C /* TrackingSlider.h */,
177EC01D0B8BC2CF0000BC8C /* TrackingSlider.m */, 177EC01D0B8BC2CF0000BC8C /* TrackingSlider.m */,
8E9A30130BA792DC0091081B /* NSFileHandle+CreateFile.h */,
8E9A30140BA792DC0091081B /* NSFileHandle+CreateFile.m */,
); );
path = Utils; path = Utils;
sourceTree = "<group>"; sourceTree = "<group>";
@ -630,6 +647,10 @@
8E75753209F31D5A0080F1EE /* PlaylistView.m */, 8E75753209F31D5A0080F1EE /* PlaylistView.m */,
8E75753309F31D5A0080F1EE /* Shuffle.h */, 8E75753309F31D5A0080F1EE /* Shuffle.h */,
8E75753409F31D5A0080F1EE /* Shuffle.m */, 8E75753409F31D5A0080F1EE /* Shuffle.m */,
8E9A2E830BA78B500091081B /* SecondsFormatter.h */,
8E9A2E840BA78B500091081B /* SecondsFormatter.m */,
8E9A2ED70BA78D9D0091081B /* IndexFormatter.h */,
8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */,
); );
path = Playlist; path = Playlist;
sourceTree = "<group>"; sourceTree = "<group>";
@ -796,6 +817,9 @@
1766C6930B911DF1004A7AE4 /* AudioScrobbler.m in Sources */, 1766C6930B911DF1004A7AE4 /* AudioScrobbler.m in Sources */,
1766C6950B911DF1004A7AE4 /* AudioScrobblerClient.m in Sources */, 1766C6950B911DF1004A7AE4 /* AudioScrobblerClient.m in Sources */,
1755E1F90BA0D2B600CA3560 /* PlaylistLoader.m in Sources */, 1755E1F90BA0D2B600CA3560 /* PlaylistLoader.m in Sources */,
8E9A2E860BA78B500091081B /* SecondsFormatter.m in Sources */,
8E9A2EDA0BA78D9D0091081B /* IndexFormatter.m in Sources */,
8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -166,6 +166,7 @@
LANGUAGE = ObjC; LANGUAGE = ObjC;
SUPERCLASS = NSObject; SUPERCLASS = NSObject;
}, },
{CLASS = SecondsFormatter; LANGUAGE = ObjC; SUPERCLASS = NSFormatter; },
{ {
ACTIONS = { ACTIONS = {
changeVolume = id; changeVolume = id;

View File

@ -7,17 +7,17 @@
<key>IBEditorPositions</key> <key>IBEditorPositions</key>
<dict> <dict>
<key>1063</key> <key>1063</key>
<string>0 320 136 49 0 0 1680 1028 </string> <string>0 228 136 49 0 0 1024 746 </string>
<key>1156</key> <key>1156</key>
<string>719 527 241 366 0 0 1680 1028 </string> <string>391 336 241 366 0 0 1024 746 </string>
<key>1324</key> <key>1324</key>
<string>788 657 137 182 0 0 1680 1028 </string> <string>453 438 137 182 0 0 1024 746 </string>
<key>29</key> <key>29</key>
<string>-3 975 383 44 0 0 1680 1028 </string> <string>-3 696 383 44 0 0 1024 746 </string>
<key>463</key> <key>463</key>
<string>669 637 341 145 0 0 1680 1028 </string> <string>341 447 341 145 0 0 1024 746 </string>
<key>513</key> <key>513</key>
<string>352 836 125 137 0 0 1680 1028 </string> <string>204 571 125 137 0 0 1024 746 </string>
</dict> </dict>
<key>IBFramework Version</key> <key>IBFramework Version</key>
<string>446.1</string> <string>446.1</string>
@ -34,16 +34,16 @@
<integer>4</integer> <integer>4</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>1307</integer>
<integer>513</integer> <integer>513</integer>
<integer>1324</integer>
<integer>21</integer>
<integer>463</integer> <integer>463</integer>
<integer>29</integer> <integer>29</integer>
<integer>21</integer>
<integer>1307</integer>
<integer>1063</integer> <integer>1063</integer>
<integer>1156</integer> <integer>1156</integer>
<integer>1324</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>8L2127</string> <string>8L127</string>
</dict> </dict>
</plist> </plist>

Binary file not shown.

View File

@ -60,6 +60,6 @@
- (void)addShuffledListToFront; - (void)addShuffledListToFront;
- (void)resetShuffleList; - (void)resetShuffleList;
- (void)handlePlaylistViewHeaderNotification:(NSNotification*)notif; - (PlaylistEntry *)entryAtIndex:(int)i;
@end @end

View File

@ -121,7 +121,7 @@
PlaylistEntry* pe; PlaylistEntry* pe;
while (pe = [enumerator nextObject]) { while (pe = [enumerator nextObject]) {
tt += [pe length]; tt += [[pe length] doubleValue];
} }
int sec = (int)(tt/1000.0); int sec = (int)(tt/1000.0);
@ -148,7 +148,7 @@
PlaylistEntry *p; PlaylistEntry *p;
p = [[self arrangedObjects] objectAtIndex:j]; p = [[self arrangedObjects] objectAtIndex:j];
[p setIndex:j]; [p setIndex:[NSNumber numberWithInt:j]];
} }
} }
@ -159,7 +159,7 @@
if ([a containsObject:currentEntry]) if ([a containsObject:currentEntry])
{ {
[currentEntry setIndex:-1]; [currentEntry setIndex:[NSNumber numberWithInt:-1]];
} }
[super removeObjectsAtArrangedObjectIndexes:indexes]; [super removeObjectsAtArrangedObjectIndexes:indexes];
@ -281,11 +281,11 @@
{ {
if (shuffle == YES) if (shuffle == YES)
{ {
return [self shuffledEntryAtIndex:[pe shuffleIndex] + 1]; return [self shuffledEntryAtIndex:([[pe shuffleIndex] intValue] + 1)];
} }
else else
{ {
return [self entryAtIndex:[pe index] + 1]; return [self entryAtIndex:([[pe index] intValue] + 1)];
} }
} }
@ -293,18 +293,18 @@
{ {
if (shuffle == YES) if (shuffle == YES)
{ {
return [self shuffledEntryAtIndex:[pe shuffleIndex] - 1]; return [self shuffledEntryAtIndex:([[pe shuffleIndex] intValue] - 1)];
} }
else else
{ {
//Fix for removing a track, then pressing prev with repeat turned on //Fix for removing a track, then pressing prev with repeat turned on
if ([pe index] == -1) if ([[pe index] intValue] == -1)
{ {
return [self entryAtIndex:[pe index]]; return [self entryAtIndex:[[pe index] intValue]];
} }
else else
{ {
return [self entryAtIndex:[pe index] - 1]; return [self entryAtIndex:[[pe index] intValue] - 1];
} }
} }
} }
@ -347,7 +347,7 @@
int i; int i;
for (i = 0; i < [shuffleList count]; i++) for (i = 0; i < [shuffleList count]; i++)
{ {
[[shuffleList objectAtIndex:i] setShuffleIndex:i]; [[shuffleList objectAtIndex:i] setShuffleIndex:[NSNumber numberWithInt:i]];
} }
} }
@ -361,7 +361,7 @@
int i; int i;
for (i = ([shuffleList count] - [newList count]); i < [shuffleList count]; i++) for (i = ([shuffleList count] - [newList count]); i < [shuffleList count]; i++)
{ {
[[shuffleList objectAtIndex:i] setShuffleIndex:i]; [[shuffleList objectAtIndex:i] setShuffleIndex:[NSNumber numberWithInt:i]];
} }
} }
@ -372,7 +372,7 @@
[self addShuffledListToFront]; [self addShuffledListToFront];
if (currentEntry && [currentEntry index] != -1) if (currentEntry && [[currentEntry index] intValue] != -1)
{ {
[shuffleList insertObject:currentEntry atIndex:0]; [shuffleList insertObject:currentEntry atIndex:0];
[currentEntry setShuffleIndex:0]; [currentEntry setShuffleIndex:0];
@ -388,7 +388,7 @@
[shuffleList removeObjectAtIndex:i]; [shuffleList removeObjectAtIndex:i];
} }
[[shuffleList objectAtIndex:i] setShuffleIndex:i]; [[shuffleList objectAtIndex:i] setShuffleIndex:[NSNumber numberWithInt:i]];
} }
} }
} }
@ -403,7 +403,7 @@
[currentEntry setCurrent:NO]; [currentEntry setCurrent:NO];
[pe setCurrent:YES]; [pe setCurrent:YES];
[tableView scrollRowToVisible:[pe index]]; [tableView scrollRowToVisible:[[pe index] intValue]];
[pe retain]; [pe retain];
[currentEntry release]; [currentEntry release];

View File

@ -17,28 +17,26 @@
NSString *genre; NSString *genre;
NSString *year; NSString *year;
unsigned int track; NSNumber *track;
NSString *lengthString; NSNumber *length;
NSNumber *bitrate;
double length; NSNumber *channels;
int bitrate; NSNumber *bitsPerSample;
int channels; NSNumber *sampleRate;
int bitsPerSample;
float sampleRate;
BOOL current; BOOL current;
int idx; //Can't use index due to some weird bug...might be fixed...should test in the future...think it was a conflict with flac, which is now an external lib NSNumber *idx;
int shuffleIdx; NSNumber *shuffleIndex;
int displayIdx; NSNumber *displayIndex;
} }
- (void)setIndex:(int)i; - (void)setIndex:(NSNumber *)i;
- (int)index; - (NSNumber *)index;
- (void)setShuffleIndex:(int)si; - (void)setShuffleIndex:(NSNumber *)si;
- (int)shuffleIndex; - (NSNumber *)shuffleIndex;
- (void)setURL:(NSURL *)u; - (void)setURL:(NSURL *)u;
- (NSURL *)url; - (NSURL *)url;
@ -54,25 +52,23 @@
- (void)setGenre:(NSString *)s; - (void)setGenre:(NSString *)s;
- (NSString *)genre; - (NSString *)genre;
- (NSString *)lengthString;
- (void)setLengthString:(double)l;
- (void)setYear:(NSString *)y; - (void)setYear:(NSString *)y;
- (NSString *)year; - (NSString *)year;
- (void)setTrack:(int)y; - (void)setTrack:(NSNumber *)y;
- (int)track; - (NSNumber *)track;
- (void)setLength:(double)l; - (void)setLength:(NSNumber *)l;
- (void)setBitrate:(int) br; - (NSNumber *)length;
- (void)setChannels:(int)c;
- (void)setBitsPerSample:(int)bps;
- (void)setSampleRate:(float)s;
- (double)length; - (void)setBitrate:(NSNumber *) br;
- (int)bitrate; - (NSNumber *)bitrate;
- (int)channels;
- (int)bitsPerSample; - (void)setChannels:(NSNumber *)c;
- (float)sampleRate; - (NSNumber *)channels;
- (void)setBitsPerSample:(NSNumber *)bps;
- (NSNumber *)bitsPerSample;
- (void)setSampleRate:(NSNumber *)s;
- (NSNumber *)sampleRate;
- (void)setMetadata: (NSDictionary *)m; - (void)setMetadata: (NSDictionary *)m;
- (void)readMetadataThread; - (void)readMetadataThread;

View File

@ -17,7 +17,7 @@
self = [super init]; self = [super init];
if (self) if (self)
{ {
[self setIndex:0]; [self setIndex:nil];
[self setURL:nil]; [self setURL:nil];
} }
@ -31,37 +31,32 @@
[super dealloc]; [super dealloc];
} }
-(void)setShuffleIndex:(int)si -(void)setShuffleIndex:(NSNumber *)si
{ {
shuffleIdx = si; [si retain];
[shuffleIndex release];
shuffleIndex = si;
} }
-(int)shuffleIndex -(NSNumber *)shuffleIndex
{ {
return shuffleIdx; return shuffleIndex;
} }
-(void)setIndex:(int)i -(void)setIndex:(NSNumber *)i
{ {
[i retain];
[idx release];
NSLog(@"INDEX: %@", i);
idx = i; idx = i;
[self setDisplayIndex:i+1];
} }
-(int)index -(NSNumber *)index
{ {
return idx; return idx;
} }
-(void)setDisplayIndex:(int)i
{
displayIdx=i;
}
-(int)displayIndex
{
return displayIdx;
}
-(void)setURL:(NSURL *)u -(void)setURL:(NSURL *)u
{ {
[u retain]; [u retain];
@ -155,24 +150,25 @@
return year; return year;
} }
- (void)setTrack:(int)t - (void)setTrack:(NSNumber *)t
{ {
[t retain];
[track release];
track = t; track = t;
} }
- (int)track - (NSNumber *)track
{ {
return track; return track;
} }
- (void)setProperties:(NSDictionary *)dict - (void)setProperties:(NSDictionary *)dict
{ {
[self setLength: [[dict objectForKey:@"length" ] doubleValue]]; [self setLength: [dict objectForKey:@"length" ]];
[self setBitrate: [[dict objectForKey:@"bitrate" ] intValue]]; [self setBitrate: [dict objectForKey:@"bitrate" ]];
[self setChannels: [[dict objectForKey:@"channels" ] intValue]]; [self setChannels: [dict objectForKey:@"channels" ]];
[self setBitsPerSample: [[dict objectForKey:@"bitsPerSample"] intValue]]; [self setBitsPerSample: [dict objectForKey:@"bitsPerSample" ]];
[self setSampleRate: [[dict objectForKey:@"sampleRate" ] floatValue]]; [self setSampleRate: [dict objectForKey:@"sampleRate" ]];
[self setLengthString:[[dict objectForKey:@"length"] doubleValue]];
} }
- (void)readPropertiesThread - (void)readPropertiesThread
@ -182,60 +178,62 @@
[self performSelectorOnMainThread:@selector(setProperties:) withObject:properties waitUntilDone:YES]; [self performSelectorOnMainThread:@selector(setProperties:) withObject:properties waitUntilDone:YES];
} }
- (NSString *)lengthString - (void)setLength:(NSNumber *)l
{ {
return lengthString; [l retain];
} [length release];
- (void)setLengthString:(double)l
{
int sec = (int)(l/1000.0);
[lengthString release];
lengthString = [[NSString alloc] initWithFormat:@"%i:%02i",sec/60,sec%60];
}
- (void)setLength:(double)l
{
length = l; length = l;
} }
- (double)length - (NSNumber *)length
{ {
return length; return length;
} }
- (void)setBitrate:(int) br - (void)setBitrate:(NSNumber *) br
{ {
[br retain];
[bitrate release];
bitrate = br; bitrate = br;
} }
- (int)bitrate - (NSNumber *)bitrate
{ {
return bitrate; return bitrate;
} }
- (void)setChannels:(int)c - (void)setChannels:(NSNumber *)c
{ {
[c retain];
[channels release];
channels = c; channels = c;
} }
- (int)channels - (NSNumber *)channels
{ {
return channels; return channels;
} }
- (void)setBitsPerSample:(int)bps - (void)setBitsPerSample:(NSNumber *)bps
{ {
[bps retain];
[bitsPerSample release];
bitsPerSample = bps; bitsPerSample = bps;
} }
- (int)bitsPerSample - (NSNumber *)bitsPerSample
{ {
return bitsPerSample; return bitsPerSample;
} }
- (void)setSampleRate:(float)s - (void)setSampleRate:(NSNumber *)s
{ {
[s retain];
[s release];
sampleRate = s; sampleRate = s;
} }
- (float)sampleRate - (NSNumber *)sampleRate
{ {
return sampleRate; return sampleRate;
} }
@ -255,7 +253,7 @@
[self setAlbum:[m objectForKey:@"album"]]; [self setAlbum:[m objectForKey:@"album"]];
[self setGenre:[m objectForKey:@"genre"]]; [self setGenre:[m objectForKey:@"genre"]];
[self setYear:[m objectForKey:@"year"]]; [self setYear:[m objectForKey:@"year"]];
[self setTrack:[[m objectForKey:@"track"] intValue]]; [self setTrack:[m objectForKey:@"track"]];
} }
- (void)readMetadataThread - (void)readMetadataThread
@ -268,7 +266,7 @@
- (NSString *)description - (NSString *)description
{ {
return [NSString stringWithFormat:@"PlaylistEntry %i:(%@)",idx, url]; return [NSString stringWithFormat:@"PlaylistEntry %i:(%@)", idx, url];
} }
@end @end

View File

@ -10,6 +10,8 @@
#import "PlaylistController.h" #import "PlaylistController.h"
#import "PlaylistEntry.h" #import "PlaylistEntry.h"
#import "NSFileHandle+CreateFile.h"
#import "CogAudio/AudioPlayer.h" #import "CogAudio/AudioPlayer.h"
@implementation PlaylistLoader @implementation PlaylistLoader
@ -136,8 +138,9 @@
- (BOOL)saveM3u:(NSString *)filename - (BOOL)saveM3u:(NSString *)filename
{ {
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename]; NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename createFile:YES];
if (!fileHandle) { if (!fileHandle) {
NSLog(@"Error!");
return NO; return NO;
} }
[fileHandle truncateFileAtOffset:0]; [fileHandle truncateFileAtOffset:0];
@ -201,7 +204,7 @@
- (BOOL)savePls:(NSString *)filename - (BOOL)savePls:(NSString *)filename
{ {
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename]; NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename createFile:YES];
if (!fileHandle) { if (!fileHandle) {
return NO; return NO;
} }
@ -327,7 +330,7 @@
NSURL *url = [finalURLs objectAtIndex:i]; NSURL *url = [finalURLs objectAtIndex:i];
[pe setURL:url]; [pe setURL:url];
[pe setIndex:index+i]; [pe setIndex:[NSNumber numberWithInt:(index+i)]];
[pe setTitle:[[url path] lastPathComponent]]; [pe setTitle:[[url path] lastPathComponent]];
[entries addObject:pe]; [entries addObject:pe];

View File

@ -12,6 +12,9 @@
#import "PlaylistHeaderView.h" #import "PlaylistHeaderView.h"
#import "IndexFormatter.h"
#import "SecondsFormatter.h"
@implementation PlaylistView @implementation PlaylistView
- (void)awakeFromNib - (void)awakeFromNib
@ -41,6 +44,14 @@
[self setHeaderView:customTableHeaderView]; [self setHeaderView:customTableHeaderView];
NSFormatter *secondsFormatter = [[SecondsFormatter alloc] init];
[[[self tableColumnWithIdentifier:@"length"] dataCell] setFormatter:secondsFormatter];
[secondsFormatter release];
NSFormatter *indexFormatter = [[IndexFormatter alloc] init];
[[[self tableColumnWithIdentifier:@"index"] dataCell] setFormatter:indexFormatter];
[indexFormatter release];
[self setVerticalMotionCanBeginDrag:YES]; [self setVerticalMotionCanBeginDrag:YES];
} }

3
TODO
View File

@ -1,5 +1,2 @@
Make playlist table header menu, (See Play _streamTableHeaderContextMenu). Make playlist table header menu, (See Play _streamTableHeaderContextMenu).
Make PlaylistEntry numbers use NSNumber.
Instead of LengthString, use a formatter.
Add automatic header seperator without testing explicit types. Pull out binding? Perhaps the table column can do a objectAtIndex and then get a stringValue to get the width.