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"
|
2022-02-16 09:52:51 +00:00
|
|
|
#import "AVIFDecoder.h"
|
2013-10-04 11:16:09 +00:00
|
|
|
#import "SecondsFormatter.h"
|
2005-06-02 18:16:43 +00:00
|
|
|
|
|
|
|
@implementation PlaylistEntry
|
|
|
|
|
2008-02-20 00:44:40 +00:00
|
|
|
@synthesize index;
|
|
|
|
@synthesize shuffleIndex;
|
2021-12-24 09:01:21 +00:00
|
|
|
@synthesize dbIndex;
|
2022-01-15 06:42:57 +00:00
|
|
|
@synthesize entryId;
|
2022-02-11 06:37:37 +00:00
|
|
|
@synthesize artId;
|
2008-03-01 03:29:21 +00:00
|
|
|
|
|
|
|
@synthesize current;
|
|
|
|
@synthesize removed;
|
|
|
|
|
|
|
|
@synthesize stopAfter;
|
|
|
|
|
|
|
|
@synthesize queued;
|
2008-02-22 15:26:46 +00:00
|
|
|
@synthesize queuePosition;
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2008-03-01 03:29:21 +00:00
|
|
|
@synthesize error;
|
|
|
|
@synthesize errorMessage;
|
|
|
|
|
2008-02-20 00:44:40 +00:00
|
|
|
@synthesize URL;
|
2022-02-16 09:52:51 +00:00
|
|
|
@synthesize trashURL;
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2008-02-20 00:44:40 +00:00
|
|
|
@synthesize artist;
|
2021-10-02 02:18:42 +00:00
|
|
|
@synthesize albumartist;
|
2008-02-20 00:44:40 +00:00
|
|
|
@synthesize album;
|
|
|
|
@synthesize genre;
|
|
|
|
@synthesize year;
|
|
|
|
@synthesize track;
|
2022-01-22 05:49:17 +00:00
|
|
|
@synthesize disc;
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2022-01-15 00:46:35 +00:00
|
|
|
@synthesize cuesheet;
|
|
|
|
|
2008-02-20 00:44:40 +00:00
|
|
|
@synthesize totalFrames;
|
|
|
|
@synthesize bitrate;
|
|
|
|
@synthesize channels;
|
2022-02-07 09:11:30 +00:00
|
|
|
@synthesize channelConfig;
|
2008-02-20 00:44:40 +00:00
|
|
|
@synthesize bitsPerSample;
|
2013-10-05 21:15:09 +00:00
|
|
|
@synthesize floatingPoint;
|
2013-10-07 18:26:23 +00:00
|
|
|
@synthesize Unsigned;
|
2008-02-20 00:44:40 +00:00
|
|
|
@synthesize sampleRate;
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2021-10-02 02:18:42 +00:00
|
|
|
@synthesize codec;
|
|
|
|
|
2013-10-02 09:30:04 +00:00
|
|
|
@synthesize replayGainAlbumGain;
|
|
|
|
@synthesize replayGainAlbumPeak;
|
|
|
|
@synthesize replayGainTrackGain;
|
|
|
|
@synthesize replayGainTrackPeak;
|
|
|
|
@synthesize volume;
|
|
|
|
|
2013-10-04 11:16:09 +00:00
|
|
|
@synthesize currentPosition;
|
|
|
|
|
2008-03-01 03:29:21 +00:00
|
|
|
@synthesize endian;
|
|
|
|
|
2022-01-22 06:38:54 +00:00
|
|
|
@synthesize encoding;
|
|
|
|
|
2008-02-20 00:44:40 +00:00
|
|
|
@synthesize seekable;
|
2006-05-12 14:41:02 +00:00
|
|
|
|
2009-03-06 04:46:42 +00:00
|
|
|
@synthesize metadataLoaded;
|
|
|
|
|
2022-02-10 05:04:17 +00:00
|
|
|
@synthesize deleted;
|
|
|
|
|
2008-02-29 21:54:09 +00:00
|
|
|
// The following read-only keys depend on the values of other properties
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingDisplay {
|
|
|
|
return [NSSet setWithObjects:@"artist", @"title", nil];
|
2008-02-29 21:54:09 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingLength {
|
2022-02-07 11:03:39 +00:00
|
|
|
return [NSSet setWithObjects:@"metadataLoaded", @"totalFrames", @"sampleRate", nil];
|
2006-05-12 14:41:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingPath {
|
|
|
|
return [NSSet setWithObject:@"URL"];
|
2008-02-29 21:54:09 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingFilename {
|
|
|
|
return [NSSet setWithObject:@"URL"];
|
2006-05-12 19:08:39 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingStatus {
|
|
|
|
return [NSSet setWithObjects:@"current", @"queued", @"error", @"stopAfter", nil];
|
2008-03-01 03:29:21 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingStatusMessage {
|
2008-03-01 03:35:27 +00:00
|
|
|
return [NSSet setWithObjects:@"current", @"queued", @"queuePosition", @"error", @"errorMessage", @"stopAfter", nil];
|
2008-03-01 03:29:21 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingSpam {
|
|
|
|
return [NSSet setWithObjects:@"albumartist", @"artist", @"title", @"album", @"track", @"disc", @"totalFrames", @"currentPosition", @"bitrate", nil];
|
2022-01-22 05:49:17 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingTrackText {
|
|
|
|
return [NSSet setWithObjects:@"track", @"disc", nil];
|
2013-10-04 11:16:09 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingYearText {
|
|
|
|
return [NSSet setWithObject:@"year"];
|
2022-01-22 07:19:32 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingCuesheetPresent {
|
|
|
|
return [NSSet setWithObject:@"cuesheet"];
|
2022-01-22 07:19:32 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingPositionText {
|
|
|
|
return [NSSet setWithObject:@"currentPosition"];
|
2014-12-04 06:13:27 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingLengthText {
|
|
|
|
return [NSSet setWithObject:@"length"];
|
2014-12-04 06:13:27 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingAlbumArt {
|
2022-02-11 06:45:26 +00:00
|
|
|
return [NSSet setWithObjects:@"albumArtInternal", @"artId", nil];
|
2013-10-09 20:53:13 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingGainCorrection {
|
|
|
|
return [NSSet setWithObjects:@"replayGainAlbumGain", @"replayGainAlbumPeak", @"replayGainTrackGain", @"replayGainTrackPeak", @"volume", nil];
|
2022-01-22 07:49:07 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (NSSet *)keyPathsForValuesAffectingGainInfo {
|
|
|
|
return [NSSet setWithObjects:@"replayGainAlbumGain", @"replayGainAlbumPeak", @"replayGainTrackGain", @"replayGainTrackPeak", @"volume", nil];
|
2022-01-23 04:44:06 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)description {
|
|
|
|
return [NSString stringWithFormat:@"PlaylistEntry %li:(%@)", self.index, self.URL];
|
2008-02-20 00:44:40 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (id)init {
|
|
|
|
if(self = [super init]) {
|
|
|
|
self.replayGainAlbumGain = 0;
|
|
|
|
self.replayGainAlbumPeak = 0;
|
|
|
|
self.replayGainTrackGain = 0;
|
|
|
|
self.replayGainTrackPeak = 0;
|
|
|
|
self.volume = 1;
|
2022-02-10 05:04:17 +00:00
|
|
|
self.deleted = NO;
|
2022-02-07 05:49:27 +00:00
|
|
|
}
|
|
|
|
return self;
|
2013-10-02 09:30:04 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)dealloc {
|
2008-03-09 02:05:00 +00:00
|
|
|
self.errorMessage = nil;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2008-03-09 02:05:00 +00:00
|
|
|
self.URL = nil;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2008-03-09 02:05:00 +00:00
|
|
|
self.artist = nil;
|
2022-02-07 05:49:27 +00:00
|
|
|
self.albumartist = nil;
|
2008-03-09 02:05:00 +00:00
|
|
|
self.album = nil;
|
|
|
|
self.title = nil;
|
|
|
|
self.genre = nil;
|
|
|
|
self.year = nil;
|
|
|
|
self.track = nil;
|
2022-02-07 05:49:27 +00:00
|
|
|
self.disc = nil;
|
2013-10-09 20:53:13 +00:00
|
|
|
self.albumArtInternal = nil;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
self.cuesheet = nil;
|
|
|
|
|
2008-03-09 02:05:00 +00:00
|
|
|
self.endian = nil;
|
2022-02-07 05:49:27 +00:00
|
|
|
self.codec = nil;
|
2008-03-09 00:22:48 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 21:54:09 +00:00
|
|
|
// Get the URL if the title is blank
|
|
|
|
@synthesize title;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)title {
|
|
|
|
if((title == nil || [title isEqualToString:@""]) && self.URL) {
|
|
|
|
return [[self.URL path] lastPathComponent];
|
|
|
|
}
|
|
|
|
return title;
|
2008-02-29 21:54:09 +00:00
|
|
|
}
|
|
|
|
|
2022-01-20 22:54:42 +00:00
|
|
|
@synthesize rawTitle;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)rawTitle {
|
|
|
|
return title;
|
2022-01-20 22:54:42 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 21:56:01 +00:00
|
|
|
@dynamic display;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)display {
|
|
|
|
if((self.artist == NULL) || ([self.artist isEqualToString:@""]))
|
2008-02-29 21:56:01 +00:00
|
|
|
return self.title;
|
|
|
|
else {
|
|
|
|
return [NSString stringWithFormat:@"%@ - %@", self.artist, self.title];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-04 11:16:09 +00:00
|
|
|
@dynamic spam;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)spam {
|
|
|
|
BOOL hasBitrate = (self.bitrate != 0);
|
|
|
|
BOOL hasArtist = (self.artist != nil) && (![self.artist isEqualToString:@""]);
|
|
|
|
BOOL hasAlbumArtist = (self.albumartist != nil) && (![self.albumartist isEqualToString:@""]);
|
|
|
|
BOOL hasAlbum = (self.album != nil) && (![self.album isEqualToString:@""]);
|
|
|
|
BOOL hasTrack = (self.track != 0);
|
|
|
|
BOOL hasLength = (self.totalFrames != 0);
|
|
|
|
BOOL hasCurrentPosition = (self.currentPosition != 0) && (self.current);
|
|
|
|
BOOL hasExtension = NO;
|
|
|
|
BOOL hasTitle = (title != nil) && (![title isEqualToString:@""]);
|
|
|
|
BOOL hasCodec = (self.codec != nil) && (![self.codec isEqualToString:@""]);
|
|
|
|
|
|
|
|
NSMutableString *filename = [NSMutableString stringWithString:[self filename]];
|
|
|
|
NSRange dotPosition = [filename rangeOfString:@"." options:NSBackwardsSearch];
|
|
|
|
NSString *extension = nil;
|
|
|
|
|
|
|
|
if(dotPosition.length > 0) {
|
|
|
|
dotPosition.location++;
|
|
|
|
dotPosition.length = [filename length] - dotPosition.location;
|
|
|
|
extension = [filename substringWithRange:dotPosition];
|
|
|
|
dotPosition.location--;
|
|
|
|
dotPosition.length++;
|
|
|
|
[filename deleteCharactersInRange:dotPosition];
|
|
|
|
hasExtension = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
NSMutableArray *elements = [NSMutableArray array];
|
|
|
|
|
|
|
|
if(hasExtension) {
|
|
|
|
[elements addObject:@"["];
|
|
|
|
if(hasCodec) {
|
|
|
|
[elements addObject:self.codec];
|
|
|
|
} else {
|
|
|
|
[elements addObject:[extension uppercaseString]];
|
|
|
|
}
|
|
|
|
if(hasBitrate) {
|
|
|
|
[elements addObject:@"@"];
|
|
|
|
[elements addObject:[NSString stringWithFormat:@"%u", self.bitrate]];
|
|
|
|
[elements addObject:@"kbps"];
|
|
|
|
}
|
|
|
|
[elements addObject:@"] "];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasArtist) {
|
|
|
|
if(hasAlbumArtist) {
|
|
|
|
[elements addObject:self.albumartist];
|
|
|
|
} else {
|
|
|
|
[elements addObject:self.artist];
|
|
|
|
}
|
|
|
|
[elements addObject:@" - "];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasAlbum) {
|
|
|
|
[elements addObject:@"["];
|
|
|
|
[elements addObject:self.album];
|
|
|
|
if(hasTrack) {
|
|
|
|
[elements addObject:@" #"];
|
|
|
|
[elements addObject:self.trackText];
|
|
|
|
}
|
|
|
|
[elements addObject:@"] "];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasTitle) {
|
|
|
|
[elements addObject:title];
|
|
|
|
} else {
|
|
|
|
[elements addObject:filename];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasAlbumArtist && hasArtist) {
|
|
|
|
[elements addObject:@" // "];
|
|
|
|
[elements addObject:self.artist];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasCurrentPosition || hasLength) {
|
|
|
|
SecondsFormatter *secondsFormatter = [[SecondsFormatter alloc] init];
|
|
|
|
[elements addObject:@" ("];
|
|
|
|
if(hasCurrentPosition) {
|
|
|
|
[elements addObject:[secondsFormatter stringForObjectValue:[NSNumber numberWithFloat:currentPosition]]];
|
|
|
|
}
|
|
|
|
if(hasLength) {
|
|
|
|
if(hasCurrentPosition) {
|
|
|
|
[elements addObject:@" / "];
|
|
|
|
}
|
|
|
|
[elements addObject:[secondsFormatter stringForObjectValue:[self length]]];
|
|
|
|
}
|
|
|
|
[elements addObject:@")"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [elements componentsJoinedByString:@""];
|
2013-10-04 11:16:09 +00:00
|
|
|
}
|
|
|
|
|
2022-01-22 05:49:17 +00:00
|
|
|
@dynamic trackText;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)trackText {
|
|
|
|
if([self.track intValue]) {
|
|
|
|
if([self.disc intValue]) {
|
|
|
|
return [NSString stringWithFormat:@"%@.%02u", self.disc, [self.track intValue]];
|
|
|
|
} else {
|
|
|
|
return [NSString stringWithFormat:@"%02u", [self.track intValue]];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return @"";
|
|
|
|
}
|
2022-01-22 05:49:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@dynamic yearText;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)yearText {
|
|
|
|
if([self.year intValue]) {
|
|
|
|
return [NSString stringWithFormat:@"%@", self.year];
|
|
|
|
} else {
|
|
|
|
return @"";
|
|
|
|
}
|
2022-01-22 05:49:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-22 07:19:32 +00:00
|
|
|
@dynamic cuesheetPresent;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)cuesheetPresent {
|
|
|
|
if(cuesheet && [cuesheet length]) {
|
|
|
|
return @"yes";
|
|
|
|
} else {
|
|
|
|
return @"no";
|
|
|
|
}
|
2022-01-22 07:19:32 +00:00
|
|
|
}
|
|
|
|
|
2022-01-22 07:49:07 +00:00
|
|
|
@dynamic gainCorrection;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)gainCorrection {
|
|
|
|
if(replayGainAlbumGain) {
|
|
|
|
if(replayGainAlbumPeak)
|
|
|
|
return @"Album Gain plus Peak";
|
|
|
|
else
|
|
|
|
return @"Album Gain";
|
|
|
|
} else if(replayGainTrackGain) {
|
|
|
|
if(replayGainTrackPeak)
|
|
|
|
return @"Track Gain plus Peak";
|
|
|
|
else
|
|
|
|
return @"Track Gain";
|
|
|
|
} else if(volume && volume != 1) {
|
|
|
|
return @"Volume scale";
|
|
|
|
} else {
|
|
|
|
return @"None";
|
|
|
|
}
|
2022-01-22 07:49:07 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 04:44:06 +00:00
|
|
|
@dynamic gainInfo;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)gainInfo {
|
|
|
|
NSMutableArray *gainItems = [[NSMutableArray alloc] init];
|
|
|
|
if(replayGainAlbumGain) {
|
|
|
|
[gainItems addObject:[NSString stringWithFormat:@"Album Gain: %+.2f dB", replayGainAlbumGain]];
|
|
|
|
}
|
|
|
|
if(replayGainAlbumPeak) {
|
|
|
|
[gainItems addObject:[NSString stringWithFormat:@"Album Peak: %.6f", replayGainAlbumPeak]];
|
|
|
|
}
|
|
|
|
if(replayGainTrackGain) {
|
|
|
|
[gainItems addObject:[NSString stringWithFormat:@"Track Gain: %+.2f dB", replayGainTrackGain]];
|
|
|
|
}
|
|
|
|
if(replayGainTrackPeak) {
|
|
|
|
[gainItems addObject:[NSString stringWithFormat:@"Track Peak: %.6f", replayGainTrackPeak]];
|
|
|
|
}
|
|
|
|
if(volume && volume != 1) {
|
|
|
|
[gainItems addObject:[NSString stringWithFormat:@"Volume Scale: %.2f%C", volume, (unichar)0x00D7]];
|
|
|
|
}
|
|
|
|
return [gainItems componentsJoinedByString:@"\n"];
|
2022-01-23 04:44:06 +00:00
|
|
|
}
|
|
|
|
|
2014-12-04 06:13:27 +00:00
|
|
|
@dynamic positionText;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)positionText {
|
|
|
|
SecondsFormatter *secondsFormatter = [[SecondsFormatter alloc] init];
|
|
|
|
NSString *time = [secondsFormatter stringForObjectValue:[NSNumber numberWithFloat:currentPosition]];
|
|
|
|
return time;
|
2014-12-04 06:13:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@dynamic lengthText;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)lengthText {
|
|
|
|
SecondsFormatter *secondsFormatter = [[SecondsFormatter alloc] init];
|
|
|
|
NSString *time = [secondsFormatter stringForObjectValue:[self length]];
|
|
|
|
return time;
|
2014-12-04 06:13:27 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 20:53:13 +00:00
|
|
|
@synthesize albumArtInternal;
|
|
|
|
|
|
|
|
@dynamic albumArt;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSImage *)albumArt {
|
2022-02-10 23:29:13 +00:00
|
|
|
if(!albumArtInternal || ![albumArtInternal length]) return nil;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2022-02-11 06:37:37 +00:00
|
|
|
NSString *imageCacheTag = [NSString stringWithFormat:@"%ld", artId];
|
2022-02-07 05:49:27 +00:00
|
|
|
NSImage *image = [NSImage imageNamed:imageCacheTag];
|
|
|
|
|
|
|
|
if(image == nil) {
|
2022-02-16 09:52:51 +00:00
|
|
|
if([AVIFDecoder isAVIFFormatForData:albumArtInternal]) {
|
|
|
|
CGImageRef imageRef = [AVIFDecoder createAVIFImageWithData:albumArtInternal];
|
|
|
|
if(imageRef) {
|
|
|
|
image = [[NSImage alloc] initWithCGImage:imageRef size:NSZeroSize];
|
|
|
|
CFRelease(imageRef);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
image = [[NSImage alloc] initWithData:albumArtInternal];
|
|
|
|
}
|
2022-02-07 05:49:27 +00:00
|
|
|
[image setName:imageCacheTag];
|
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAlbumArt:(id)data {
|
|
|
|
if([data isKindOfClass:[NSData class]]) {
|
|
|
|
[self setAlbumArtInternal:data];
|
|
|
|
}
|
2013-10-09 20:53:13 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 20:09:59 +00:00
|
|
|
@dynamic length;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSNumber *)length {
|
|
|
|
return [NSNumber numberWithDouble:(self.metadataLoaded) ? ((double)self.totalFrames / self.sampleRate) : 0.0];
|
2008-02-20 00:44:40 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 20:09:59 +00:00
|
|
|
@dynamic path;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)path {
|
|
|
|
if([self.URL isFileURL])
|
|
|
|
return [[self.URL path] stringByAbbreviatingWithTildeInPath];
|
|
|
|
else
|
|
|
|
return [self.URL absoluteString];
|
2008-02-20 00:44:40 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 20:09:59 +00:00
|
|
|
@dynamic filename;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)filename {
|
2008-02-20 00:44:40 +00:00
|
|
|
return [[self.URL path] lastPathComponent];
|
2007-11-24 20:16:27 +00:00
|
|
|
}
|
|
|
|
|
2008-03-01 03:29:21 +00:00
|
|
|
@dynamic status;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)status {
|
|
|
|
if(self.stopAfter) {
|
2008-03-01 03:29:21 +00:00
|
|
|
return @"stopAfter";
|
2022-02-07 05:49:27 +00:00
|
|
|
} else if(self.current) {
|
2008-03-01 03:29:21 +00:00
|
|
|
return @"playing";
|
2022-02-07 05:49:27 +00:00
|
|
|
} else if(self.queued) {
|
2008-03-01 03:29:21 +00:00
|
|
|
return @"queued";
|
2022-02-07 05:49:27 +00:00
|
|
|
} else if(self.error) {
|
2008-03-01 03:29:21 +00:00
|
|
|
return @"error";
|
|
|
|
}
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2008-03-01 03:29:21 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
@dynamic statusMessage;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)statusMessage {
|
|
|
|
if(self.stopAfter) {
|
2008-03-01 03:29:21 +00:00
|
|
|
return @"Stopping once finished...";
|
2022-02-07 05:49:27 +00:00
|
|
|
} else if(self.current) {
|
2008-03-01 03:29:21 +00:00
|
|
|
return @"Playing...";
|
2022-02-07 05:49:27 +00:00
|
|
|
} else if(self.queued) {
|
|
|
|
return [NSString stringWithFormat:@"Queued: %li", self.queuePosition + 1];
|
|
|
|
} else if(self.error) {
|
2008-03-01 03:29:21 +00:00
|
|
|
return errorMessage;
|
|
|
|
}
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2008-03-01 03:29:21 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)setMetadata:(NSDictionary *)metadata {
|
|
|
|
if(metadata == nil) {
|
|
|
|
self.error = YES;
|
|
|
|
self.errorMessage = @"Unable to retrieve metadata.";
|
|
|
|
} else {
|
2009-03-06 04:46:42 +00:00
|
|
|
[self setValuesForKeysWithDictionary:metadata];
|
2022-02-07 05:49:27 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 11:03:39 +00:00
|
|
|
[self setMetadataLoaded:YES];
|
2009-03-06 04:46:42 +00:00
|
|
|
}
|
|
|
|
|
2022-01-20 07:23:17 +00:00
|
|
|
- (id)copyWithZone:(NSZone *)zone {
|
2022-02-07 05:49:27 +00:00
|
|
|
PlaylistEntry *pe = [[[self class] allocWithZone:zone] init];
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
if(pe) {
|
|
|
|
pe->index = index;
|
|
|
|
pe->shuffleIndex = shuffleIndex;
|
|
|
|
pe->dbIndex = dbIndex;
|
|
|
|
pe->entryId = entryId;
|
2022-02-11 06:37:37 +00:00
|
|
|
pe->artId = artId;
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->current = current;
|
|
|
|
pe->removed = removed;
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->stopAfter = stopAfter;
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->queued = queued;
|
|
|
|
pe->queuePosition = queuePosition;
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->error = error;
|
|
|
|
pe->errorMessage = [errorMessage copyWithZone:zone];
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->URL = [URL copyWithZone:zone];
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->artist = [artist copyWithZone:zone];
|
|
|
|
pe->albumartist = [albumartist copyWithZone:zone];
|
|
|
|
pe->album = [album copyWithZone:zone];
|
|
|
|
pe->title = [title copyWithZone:zone];
|
|
|
|
pe->genre = [genre copyWithZone:zone];
|
|
|
|
pe->year = [year copyWithZone:zone];
|
|
|
|
pe->track = [track copyWithZone:zone];
|
|
|
|
pe->disc = [disc copyWithZone:zone];
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->cuesheet = [cuesheet copyWithZone:zone];
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-11 06:37:37 +00:00
|
|
|
pe->albumArtInternal = albumArtInternal; // Only allocated item not duplicated
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->replayGainAlbumGain = replayGainAlbumGain;
|
|
|
|
pe->replayGainAlbumPeak = replayGainAlbumPeak;
|
|
|
|
pe->replayGainTrackGain = replayGainTrackGain;
|
|
|
|
pe->replayGainTrackPeak = replayGainTrackPeak;
|
|
|
|
pe->volume = volume;
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
currentPosition = pe->currentPosition;
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->totalFrames = totalFrames;
|
|
|
|
pe->bitrate = bitrate;
|
|
|
|
pe->channels = channels;
|
2022-02-07 09:11:30 +00:00
|
|
|
pe->channelConfig = channelConfig;
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->bitsPerSample = bitsPerSample;
|
|
|
|
pe->floatingPoint = floatingPoint;
|
|
|
|
pe->Unsigned = Unsigned;
|
|
|
|
pe->sampleRate = sampleRate;
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->codec = [codec copyWithZone:zone];
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->endian = [endian copyWithZone:zone];
|
2022-01-20 22:54:42 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
pe->encoding = [encoding copyWithZone:zone];
|
|
|
|
|
|
|
|
pe->seekable = seekable;
|
|
|
|
|
|
|
|
pe->metadataLoaded = metadataLoaded;
|
2022-02-10 05:04:17 +00:00
|
|
|
|
|
|
|
pe->deleted = deleted;
|
2022-02-07 05:49:27 +00:00
|
|
|
}
|
2022-01-20 07:23:17 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
return pe;
|
2022-01-20 07:23:17 +00:00
|
|
|
}
|
|
|
|
|
2005-06-02 18:16:43 +00:00
|
|
|
@end
|