cog/Playlist/PlaylistEntry.m

306 lines
4.2 KiB
Matlab
Raw Normal View History

2005-06-02 18:16:43 +00:00
//
// PlaylistEntry.m
// Cog
//
// Created by Vincent Spader on 3/14/05.
2005-07-02 21:02:06 +00:00
// Copyright 2005 Vincent Spader All rights reserved.
2005-06-02 18:16:43 +00:00
//
#import "PlaylistEntry.h"
#import "CogAudio/AudioPropertiesReader.h"
#import "CogAudio/AudioMetadataReader.h"
2005-06-02 18:16:43 +00:00
@implementation PlaylistEntry
- (id)init
{
self = [super init];
if (self)
{
url = nil;
artist = nil;
album = nil;
title = nil;
genre = nil;
year = nil;
track = nil;
length = nil;
bitrate = nil;
channels = nil;
bitsPerSample = nil;
sampleRate = nil;
current = nil;
idx = nil;
shuffleIndex = nil;
2005-06-02 18:16:43 +00:00
}
return self;
}
- (void)dealloc
{
[url release];
[artist release];
[album release];
[title release];
[genre release];
[year release];
[track release];
[length release];
[bitrate release];
[channels release];
[bitsPerSample release];
[sampleRate release];
[current release];
[idx release];
[shuffleIndex release];
2005-06-02 18:16:43 +00:00
[super dealloc];
}
-(void)setShuffleIndex:(NSNumber *)si
{
[si retain];
[shuffleIndex release];
shuffleIndex = si;
}
-(NSNumber *)shuffleIndex
{
return shuffleIndex;
}
2005-06-02 18:16:43 +00:00
-(void)setIndex:(NSNumber *)i
2005-06-02 18:16:43 +00:00
{
[i retain];
[idx release];
NSLog(@"INDEX: %@", i);
2005-06-02 18:16:43 +00:00
idx = i;
}
2006-04-15 14:17:46 +00:00
-(NSNumber *)index
2005-06-02 18:16:43 +00:00
{
return idx;
}
-(void)setURL:(NSURL *)u
2005-06-02 18:16:43 +00:00
{
[u retain];
[url release];
url = u;
2005-06-02 18:16:43 +00:00
}
-(NSURL *)url
2005-06-02 18:16:43 +00:00
{
return url;
2005-06-02 18:16:43 +00:00
}
-(void)setCurrent:(NSNumber *) b
2005-06-02 18:16:43 +00:00
{
[b retain];
[current release];
2005-06-02 18:16:43 +00:00
current = b;
}
-(NSNumber *)current
2005-06-02 18:16:43 +00:00
{
return current;
}
- (void)setArtist:(NSString *)s
{
[s retain];
[artist release];
artist = s;
}
- (NSString *)artist
{
return artist;
}
- (void)setAlbum:(NSString *)s
{
[s retain];
[album release];
album = s;
}
- (NSString *)album
{
return album;
}
- (void)setTitle:(NSString *)s
{
[s retain];
[title release];
title = s;
}
- (NSString *)title
{
// DBLog(@"HERE FUCK: %@", title);
return title;
}
- (void)setGenre:(NSString *)s
{
[s retain];
[genre release];
genre = s;
}
- (NSString *)genre
{
return genre;
}
2006-05-12 21:49:51 +00:00
- (void)setYear:(NSString *)y
2006-05-12 14:41:02 +00:00
{
2006-05-12 21:49:51 +00:00
[y retain];
[year release];
if ([y intValue] == 0)
{
y = @"";
}
2006-05-12 14:41:02 +00:00
year = y;
}
2006-05-12 21:49:51 +00:00
- (NSString *)year
2006-05-12 14:41:02 +00:00
{
return year;
}
- (void)setTrack:(NSNumber *)t
2006-05-12 14:41:02 +00:00
{
[t retain];
[track release];
2006-05-12 14:41:02 +00:00
track = t;
}
- (NSNumber *)track
2006-05-12 14:41:02 +00:00
{
return track;
}
- (void)setProperties:(NSDictionary *)dict
2005-06-02 18:16:43 +00:00
{
[self setLength: [dict objectForKey:@"length" ]];
[self setBitrate: [dict objectForKey:@"bitrate" ]];
[self setChannels: [dict objectForKey:@"channels" ]];
[self setBitsPerSample: [dict objectForKey:@"bitsPerSample" ]];
[self setSampleRate: [dict objectForKey:@"sampleRate" ]];
2006-05-12 19:08:39 +00:00
}
- (void)readPropertiesThread
2006-05-12 19:08:39 +00:00
{
NSDictionary *properties = [AudioPropertiesReader propertiesForURL:url];
2006-05-12 19:08:39 +00:00
[self performSelectorOnMainThread:@selector(setProperties:) withObject:properties waitUntilDone:YES];
2006-05-12 19:08:39 +00:00
}
- (void)setLength:(NSNumber *)l
{
[l retain];
[length release];
length = l;
}
- (NSNumber *)length
2005-06-02 18:16:43 +00:00
{
return length;
}
- (void)setBitrate:(NSNumber *) br
{
[br retain];
[bitrate release];
2006-06-19 00:39:41 +00:00
bitrate = br;
}
- (NSNumber *)bitrate
2005-06-02 18:16:43 +00:00
{
2006-06-19 00:39:41 +00:00
return bitrate;
2005-06-02 18:16:43 +00:00
}
- (void)setChannels:(NSNumber *)c
{
[c retain];
[channels release];
channels = c;
}
- (NSNumber *)channels
2005-06-02 18:16:43 +00:00
{
return channels;
}
- (void)setBitsPerSample:(NSNumber *)bps
{
[bps retain];
[bitsPerSample release];
bitsPerSample = bps;
}
- (NSNumber *)bitsPerSample
2005-06-02 18:16:43 +00:00
{
return bitsPerSample;
}
- (void)setSampleRate:(NSNumber *)s
{
[s retain];
[sampleRate release];
sampleRate = s;
}
- (NSNumber *)sampleRate
2005-06-02 18:16:43 +00:00
{
return sampleRate;
}
- (void)setMetadata: (NSDictionary *)m
2005-06-02 18:16:43 +00:00
{
NSString *ti = [m objectForKey:@"title"];
if ([ti isEqualToString:@""]) {
[self setTitle:[[url path] lastPathComponent]];
2005-06-02 18:16:43 +00:00
}
else {
[self setTitle:ti];
}
[self setArtist:[m objectForKey:@"artist"]];
[self setAlbum:[m objectForKey:@"album"]];
[self setGenre:[m objectForKey:@"genre"]];
[self setYear:[m objectForKey:@"year"]];
[self setTrack:[m objectForKey:@"track"]];
2006-05-12 19:08:39 +00:00
}
- (void)readMetadataThread
2006-05-12 19:08:39 +00:00
{
NSDictionary *metadata = [AudioMetadataReader metadataForURL:url];
2006-05-12 19:08:39 +00:00
[self performSelectorOnMainThread:@selector(setMetadata:) withObject:metadata waitUntilDone:YES];
2006-05-12 19:08:39 +00:00
}
- (NSString *)description
{
return [NSString stringWithFormat:@"PlaylistEntry %i:(%@)", idx, url];
}
2005-06-02 18:16:43 +00:00
@end