Added RepeatTransformers with the beginnings of support for the repeat modes. MenuItems's reflect the repeat state (yet do not work to set the state yet), and the repeat button toggles w/images as expected..
parent
94f23c4fdb
commit
8434f6e3b3
|
@ -35,8 +35,6 @@
|
|||
1766C8930B912FB4004A7AE4 /* files_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C88B0B912FB4004A7AE4 /* files_on.png */; };
|
||||
1766C8940B912FB4004A7AE4 /* info_off.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C88C0B912FB4004A7AE4 /* info_off.png */; };
|
||||
1766C8950B912FB4004A7AE4 /* info_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C88D0B912FB4004A7AE4 /* info_on.png */; };
|
||||
1766C8960B912FB4004A7AE4 /* repeat_off.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C88E0B912FB4004A7AE4 /* repeat_off.png */; };
|
||||
1766C8970B912FB4004A7AE4 /* repeat_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C88F0B912FB4004A7AE4 /* repeat_on.png */; };
|
||||
1766C8980B912FB4004A7AE4 /* shuffle_off.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C8900B912FB4004A7AE4 /* shuffle_off.png */; };
|
||||
1766C8990B912FB4004A7AE4 /* shuffle_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C8910B912FB4004A7AE4 /* shuffle_on.png */; };
|
||||
1770429C0B8BC53600B86321 /* AppController.m in Sources */ = {isa = PBXBuildFile; fileRef = 177042980B8BC53600B86321 /* AppController.m */; };
|
||||
|
@ -74,6 +72,10 @@
|
|||
1791005F0CB44D6D0070BC5C /* Cog.scriptTerminology in Resources */ = {isa = PBXBuildFile; fileRef = 1791005D0CB44D6D0070BC5C /* Cog.scriptTerminology */; };
|
||||
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 1791FF8E0CB43A2C0070BC5C /* MediaKeysApplication.m */; };
|
||||
179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 179790DF0C087AB7001D6996 /* OpenURLPanel.m */; };
|
||||
17A8F6370D6A7B0F0095DA13 /* RepeatTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = 17A8F6360D6A7B0F0095DA13 /* RepeatTransformers.m */; };
|
||||
17A8F6850D6A7FCA0095DA13 /* repeat_all.png in Resources */ = {isa = PBXBuildFile; fileRef = 17A8F6820D6A7FCA0095DA13 /* repeat_all.png */; };
|
||||
17A8F6860D6A7FCA0095DA13 /* repeat_none.png in Resources */ = {isa = PBXBuildFile; fileRef = 17A8F6830D6A7FCA0095DA13 /* repeat_none.png */; };
|
||||
17A8F6870D6A7FCA0095DA13 /* repeat_one.png in Resources */ = {isa = PBXBuildFile; fileRef = 17A8F6840D6A7FCA0095DA13 /* repeat_one.png */; };
|
||||
17B6FA7F0D48225300C3BEF1 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17BF2B270CDD77EB007E1295 /* Sparkle.framework */; };
|
||||
17BB5CED0B8A86010009ACB1 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17BB5CEC0B8A86010009ACB1 /* AudioToolbox.framework */; };
|
||||
17BB5CF90B8A86350009ACB1 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17BB5CF60B8A86350009ACB1 /* AudioUnit.framework */; };
|
||||
|
@ -510,8 +512,6 @@
|
|||
1766C88B0B912FB4004A7AE4 /* files_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = files_on.png; path = Images/files_on.png; sourceTree = "<group>"; };
|
||||
1766C88C0B912FB4004A7AE4 /* info_off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = info_off.png; path = Images/info_off.png; sourceTree = "<group>"; };
|
||||
1766C88D0B912FB4004A7AE4 /* info_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = info_on.png; path = Images/info_on.png; sourceTree = "<group>"; };
|
||||
1766C88E0B912FB4004A7AE4 /* repeat_off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_off.png; path = Images/repeat_off.png; sourceTree = "<group>"; };
|
||||
1766C88F0B912FB4004A7AE4 /* repeat_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_on.png; path = Images/repeat_on.png; sourceTree = "<group>"; };
|
||||
1766C8900B912FB4004A7AE4 /* shuffle_off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = shuffle_off.png; path = Images/shuffle_off.png; sourceTree = "<group>"; };
|
||||
1766C8910B912FB4004A7AE4 /* shuffle_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = shuffle_on.png; path = Images/shuffle_on.png; sourceTree = "<group>"; };
|
||||
1770424E0B8BC41800B86321 /* Cog.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Cog.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -566,6 +566,11 @@
|
|||
1791FF8E0CB43A2C0070BC5C /* MediaKeysApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MediaKeysApplication.m; sourceTree = "<group>"; };
|
||||
179790DE0C087AB7001D6996 /* OpenURLPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OpenURLPanel.h; sourceTree = "<group>"; };
|
||||
179790DF0C087AB7001D6996 /* OpenURLPanel.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = OpenURLPanel.m; sourceTree = "<group>"; };
|
||||
17A8F6350D6A7B0F0095DA13 /* RepeatTransformers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RepeatTransformers.h; sourceTree = "<group>"; };
|
||||
17A8F6360D6A7B0F0095DA13 /* RepeatTransformers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RepeatTransformers.m; sourceTree = "<group>"; };
|
||||
17A8F6820D6A7FCA0095DA13 /* repeat_all.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_all.png; path = Images/repeat_all.png; sourceTree = "<group>"; };
|
||||
17A8F6830D6A7FCA0095DA13 /* repeat_none.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_none.png; path = Images/repeat_none.png; sourceTree = "<group>"; };
|
||||
17A8F6840D6A7FCA0095DA13 /* repeat_one.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_one.png; path = Images/repeat_one.png; sourceTree = "<group>"; };
|
||||
17BB5CEC0B8A86010009ACB1 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
|
||||
17BB5CF60B8A86350009ACB1 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = "<absolute>"; };
|
||||
17BB5CF70B8A86350009ACB1 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = /System/Library/Frameworks/CoreAudio.framework; sourceTree = "<absolute>"; };
|
||||
|
@ -843,12 +848,13 @@
|
|||
177EC02D0B8BC2E60000BC8C /* Images */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
17A8F6820D6A7FCA0095DA13 /* repeat_all.png */,
|
||||
17A8F6830D6A7FCA0095DA13 /* repeat_none.png */,
|
||||
17A8F6840D6A7FCA0095DA13 /* repeat_one.png */,
|
||||
1766C88A0B912FB4004A7AE4 /* files_off.png */,
|
||||
1766C88B0B912FB4004A7AE4 /* files_on.png */,
|
||||
1766C88C0B912FB4004A7AE4 /* info_off.png */,
|
||||
1766C88D0B912FB4004A7AE4 /* info_on.png */,
|
||||
1766C88E0B912FB4004A7AE4 /* repeat_off.png */,
|
||||
1766C88F0B912FB4004A7AE4 /* repeat_on.png */,
|
||||
1766C8900B912FB4004A7AE4 /* shuffle_off.png */,
|
||||
1766C8910B912FB4004A7AE4 /* shuffle_on.png */,
|
||||
177EC02E0B8BC2FF0000BC8C /* add_blue.png */,
|
||||
|
@ -1180,18 +1186,18 @@
|
|||
8E75752A09F31D5A0080F1EE /* Playlist */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8E75752D09F31D5A0080F1EE /* PlaylistController.h */,
|
||||
8E75752E09F31D5A0080F1EE /* PlaylistController.m */,
|
||||
8E75753109F31D5A0080F1EE /* PlaylistView.h */,
|
||||
8E75753209F31D5A0080F1EE /* PlaylistView.m */,
|
||||
8E1296D80A2BA9CE00443124 /* PlaylistHeaderView.h */,
|
||||
8E1296D90A2BA9CE00443124 /* PlaylistHeaderView.m */,
|
||||
1755E1F60BA0D2B600CA3560 /* PlaylistLoader.h */,
|
||||
1755E1F70BA0D2B600CA3560 /* PlaylistLoader.m */,
|
||||
8E75752B09F31D5A0080F1EE /* DNDArrayController.h */,
|
||||
8E75752C09F31D5A0080F1EE /* DNDArrayController.m */,
|
||||
8E75752D09F31D5A0080F1EE /* PlaylistController.h */,
|
||||
8E75752E09F31D5A0080F1EE /* PlaylistController.m */,
|
||||
8E75752F09F31D5A0080F1EE /* PlaylistEntry.h */,
|
||||
8E75753009F31D5A0080F1EE /* PlaylistEntry.m */,
|
||||
8E75753109F31D5A0080F1EE /* PlaylistView.h */,
|
||||
8E75753209F31D5A0080F1EE /* PlaylistView.m */,
|
||||
8E75753309F31D5A0080F1EE /* Shuffle.h */,
|
||||
8E75753409F31D5A0080F1EE /* Shuffle.m */,
|
||||
8E9A2E830BA78B500091081B /* SecondsFormatter.h */,
|
||||
|
@ -1200,6 +1206,8 @@
|
|||
8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */,
|
||||
173428F30D5FB1C400E8D854 /* EntriesController.h */,
|
||||
173428F40D5FB1C400E8D854 /* EntriesController.m */,
|
||||
17A8F6350D6A7B0F0095DA13 /* RepeatTransformers.h */,
|
||||
17A8F6360D6A7B0F0095DA13 /* RepeatTransformers.m */,
|
||||
);
|
||||
path = Playlist;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1566,8 +1574,6 @@
|
|||
1766C8930B912FB4004A7AE4 /* files_on.png in Resources */,
|
||||
1766C8940B912FB4004A7AE4 /* info_off.png in Resources */,
|
||||
1766C8950B912FB4004A7AE4 /* info_on.png in Resources */,
|
||||
1766C8960B912FB4004A7AE4 /* repeat_off.png in Resources */,
|
||||
1766C8970B912FB4004A7AE4 /* repeat_on.png in Resources */,
|
||||
1766C8980B912FB4004A7AE4 /* shuffle_off.png in Resources */,
|
||||
1766C8990B912FB4004A7AE4 /* shuffle_on.png in Resources */,
|
||||
171B57DD0C091F2B00F6AFAF /* flac.icns in Resources */,
|
||||
|
@ -1594,6 +1600,9 @@
|
|||
17342ABF0D5FD36400E8D854 /* OpenURLPanel.xib in Resources */,
|
||||
5604D4580D603459004F5C5D /* SpotlightPanel.xib in Resources */,
|
||||
17211A7E0D68B7C500911CA9 /* FileTreePanel.xib in Resources */,
|
||||
17A8F6850D6A7FCA0095DA13 /* repeat_all.png in Resources */,
|
||||
17A8F6860D6A7FCA0095DA13 /* repeat_none.png in Resources */,
|
||||
17A8F6870D6A7FCA0095DA13 /* repeat_one.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -1660,6 +1669,7 @@
|
|||
17E78CB10D68D46F005C5A59 /* StringToURLTransformer.m in Sources */,
|
||||
56AE86C10D6901BC00B0F89B /* FontSizetoLineHeightTransformer.m in Sources */,
|
||||
171192BD0D691ED600FD76C5 /* PathWatcher.m in Sources */,
|
||||
17A8F6370D6A7B0F0095DA13 /* RepeatTransformers.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 413 B After Width: | Height: | Size: 413 B |
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
Binary file not shown.
After Width: | Height: | Size: 417 B |
|
@ -4,3 +4,6 @@ does not resize columns (needs a lower bound)
|
|||
Code for fading and seeking should be moved into the AudioPlayer,
|
||||
so we can escape ugly event* functions
|
||||
|
||||
Repeat MenuItems do not actually set the mode directly, but just toggles.
|
||||
|
||||
mp3 bitrate is a tad off.
|
|
@ -15,6 +15,12 @@
|
|||
@class EntriesController;
|
||||
@class SpotlightWindowController;
|
||||
|
||||
typedef enum {
|
||||
RepeatNone = 0,
|
||||
RepeatOne,
|
||||
RepeatAll
|
||||
} RepeatMode;
|
||||
|
||||
@interface PlaylistController : DNDArrayController {
|
||||
IBOutlet PlaylistLoader *playlistLoader;
|
||||
IBOutlet EntriesController *entriesController;
|
||||
|
@ -27,7 +33,7 @@
|
|||
PlaylistEntry *currentEntry;
|
||||
|
||||
BOOL shuffle;
|
||||
BOOL repeat;
|
||||
RepeatMode repeat;
|
||||
|
||||
int selectedRow;
|
||||
}
|
||||
|
@ -40,8 +46,8 @@
|
|||
//PUBLIC METHODS
|
||||
- (void)setShuffle:(BOOL)s;
|
||||
- (BOOL)shuffle;
|
||||
- (void)setRepeat:(BOOL)r;
|
||||
- (BOOL)repeat;
|
||||
- (void)setRepeat:(RepeatMode)r;
|
||||
- (RepeatMode)repeat;
|
||||
|
||||
- (PlaylistEntry *)getNextEntry:(PlaylistEntry *)pe;
|
||||
- (PlaylistEntry *)getPrevEntry:(PlaylistEntry *)pe;
|
||||
|
@ -50,7 +56,7 @@
|
|||
- (NSUndoManager *)undoManager;
|
||||
|
||||
- (IBAction)takeShuffleFromObject:(id)sender;
|
||||
- (IBAction)takeRepeatFromObject:(id)sender;
|
||||
- (IBAction)toggleRepeat:(id)sender;
|
||||
|
||||
- (IBAction)sortByPath;
|
||||
- (IBAction)randomizeList;
|
||||
|
|
|
@ -11,13 +11,31 @@
|
|||
#import "PlaylistEntry.h"
|
||||
#import "Shuffle.h"
|
||||
#import "SpotlightWindowController.h"
|
||||
|
||||
#import "RepeatTransformers.h"
|
||||
#import "CogAudio/AudioPlayer.h"
|
||||
|
||||
@implementation PlaylistController
|
||||
|
||||
#define SHUFFLE_HISTORY_SIZE 100
|
||||
|
||||
+ (void)initialize {
|
||||
NSValueTransformer *repeatNoneTransformer = [[[RepeatModeTransformer alloc] initWithMode:RepeatNone] autorelease];
|
||||
[NSValueTransformer setValueTransformer:repeatNoneTransformer
|
||||
forName:@"RepeatNoneTransformer"];
|
||||
|
||||
NSValueTransformer *repeatOneTransformer = [[[RepeatModeTransformer alloc] initWithMode:RepeatOne] autorelease];
|
||||
[NSValueTransformer setValueTransformer:repeatOneTransformer
|
||||
forName:@"RepeatOneTransformer"];
|
||||
|
||||
NSValueTransformer *repeatAllTransformer = [[[RepeatModeTransformer alloc] initWithMode:RepeatAll] autorelease];
|
||||
[NSValueTransformer setValueTransformer:repeatAllTransformer
|
||||
forName:@"RepeatAllTransformer"];
|
||||
|
||||
NSValueTransformer *repeatModeImageTransformer = [[[RepeatModeImageTransformer alloc] init]autorelease];
|
||||
[NSValueTransformer setValueTransformer:repeatModeImageTransformer
|
||||
forName:@"RepeatModeImageTransformer"];
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
self = [super initWithCoder:decoder];
|
||||
|
@ -285,12 +303,17 @@
|
|||
else
|
||||
[self setShuffle: [sender state]];
|
||||
}
|
||||
- (IBAction)takeRepeatFromObject:(id)sender
|
||||
- (IBAction)toggleRepeat:(id)sender
|
||||
{
|
||||
if( [sender respondsToSelector: @selector(boolValue)] )
|
||||
[self setRepeat: [sender boolValue]];
|
||||
else
|
||||
[self setRepeat: [sender state]];
|
||||
if (repeat == RepeatNone) {
|
||||
[self setRepeat: RepeatOne];
|
||||
}
|
||||
else if (repeat == RepeatOne) {
|
||||
[self setRepeat: RepeatAll];
|
||||
}
|
||||
else if (repeat == RepeatAll) {
|
||||
[self setRepeat: RepeatNone];
|
||||
}
|
||||
}
|
||||
|
||||
- (PlaylistEntry *)entryAtIndex:(int)i
|
||||
|
@ -498,11 +521,12 @@
|
|||
{
|
||||
return shuffle;
|
||||
}
|
||||
- (void)setRepeat:(BOOL)r
|
||||
- (void)setRepeat:(RepeatMode)r
|
||||
{
|
||||
NSLog(@"Repeat is now: %i", r);
|
||||
repeat = r;
|
||||
}
|
||||
- (BOOL)repeat
|
||||
- (RepeatMode)repeat
|
||||
{
|
||||
return repeat;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// RepeatModeTransformer.h
|
||||
// Cog
|
||||
//
|
||||
// Created by Vincent Spader on 2/18/08.
|
||||
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "PlaylistController.h"
|
||||
|
||||
@interface RepeatModeTransformer : NSValueTransformer {
|
||||
RepeatMode repeatMode;
|
||||
}
|
||||
|
||||
- (id)initWithMode:(RepeatMode) r;
|
||||
|
||||
@end
|
||||
|
||||
@interface RepeatModeImageTransformer : NSValueTransformer {}
|
||||
@end
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
//
|
||||
// RepeatModeTransformer.m
|
||||
// Cog
|
||||
//
|
||||
// Created by Vincent Spader on 2/18/08.
|
||||
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RepeatTransformers.h"
|
||||
#import "PlaylistController.h"
|
||||
|
||||
@implementation RepeatModeTransformer
|
||||
|
||||
+ (Class)transformedValueClass { return [NSNumber class]; }
|
||||
+ (BOOL)allowsReverseTransformation { return NO; }
|
||||
|
||||
- (id)initWithMode:(RepeatMode) r
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
repeatMode = r;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// Convert from RepeatMode to BOOL
|
||||
- (id)transformedValue:(id)value {
|
||||
NSLog(@"Transforming value: %@", value);
|
||||
|
||||
if (value == nil) return nil;
|
||||
|
||||
RepeatMode mode = [value integerValue];
|
||||
|
||||
if (repeatMode == mode) {
|
||||
return [NSNumber numberWithBool:YES];
|
||||
}
|
||||
|
||||
|
||||
return [NSNumber numberWithBool:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RepeatModeImageTransformer
|
||||
|
||||
+ (Class)transformedValueClass { return [NSImage class]; }
|
||||
+ (BOOL)allowsReverseTransformation { return NO; }
|
||||
|
||||
// Convert from string to RepeatMode
|
||||
- (id)transformedValue:(id)value {
|
||||
NSLog(@"Transforming value: %@", value);
|
||||
|
||||
if (value == nil) return nil;
|
||||
|
||||
RepeatMode mode = [value integerValue];
|
||||
|
||||
if (mode == RepeatNone) {
|
||||
return [NSImage imageNamed:@"repeat_none"];
|
||||
}
|
||||
else if (mode == RepeatOne) {
|
||||
return [NSImage imageNamed:@"repeat_one"];
|
||||
}
|
||||
else if (mode == RepeatAll) {
|
||||
return [NSImage imageNamed:@"repeat_all"];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
|
@ -271,7 +271,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
bitrate = ((_fileSize - id3_length)/128) * (sampleRate/totalFrames);
|
||||
bitrate = (((_fileSize - id3_length)*8)/1000) * (sampleRate/totalFrames);
|
||||
|
||||
mad_frame_finish (&frame);
|
||||
mad_stream_finish (&stream);
|
||||
|
|
Loading…
Reference in New Issue