2005-06-02 18:16:43 +00:00
|
|
|
//
|
|
|
|
// PlaylistController.h
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 3/18/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 <Cocoa/Cocoa.h>
|
2022-06-16 14:14:33 +00:00
|
|
|
#import <CoreData/CoreData.h>
|
2008-02-10 16:16:45 +00:00
|
|
|
#import <Foundation/NSUndoManager.h>
|
2007-03-09 01:16:06 +00:00
|
|
|
|
2022-06-16 14:14:33 +00:00
|
|
|
#import "DNDArrayController.h"
|
|
|
|
|
|
|
|
@class AlbumArtwork;
|
|
|
|
|
2007-03-09 01:16:06 +00:00
|
|
|
@class PlaylistLoader;
|
|
|
|
@class PlaylistEntry;
|
2008-02-16 16:13:21 +00:00
|
|
|
@class SpotlightWindowController;
|
2008-05-09 21:24:49 +00:00
|
|
|
@class PlaybackController;
|
2022-06-24 07:29:50 +00:00
|
|
|
@class AppController;
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2021-01-30 23:14:08 +00:00
|
|
|
typedef NS_ENUM(NSInteger, RepeatMode) {
|
2022-02-07 05:49:27 +00:00
|
|
|
RepeatModeNoRepeat = 0,
|
|
|
|
RepeatModeRepeatOne,
|
|
|
|
RepeatModeRepeatAlbum,
|
|
|
|
RepeatModeRepeatAll
|
2021-01-30 23:14:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline BOOL IsRepeatOneSet() {
|
2022-02-07 05:49:27 +00:00
|
|
|
return [[NSUserDefaults standardUserDefaults] integerForKey:@"repeat"] == RepeatModeRepeatOne;
|
2014-02-14 05:16:18 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
typedef enum { ShuffleOff = 0,
|
|
|
|
ShuffleAlbums,
|
|
|
|
ShuffleAll } ShuffleMode;
|
2021-01-30 23:14:08 +00:00
|
|
|
|
|
|
|
typedef NS_ENUM(NSInteger, URLOrigin) {
|
2022-02-07 05:49:27 +00:00
|
|
|
URLOriginInternal = 0,
|
|
|
|
URLOriginExternal
|
2021-01-30 23:14:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@interface PlaylistController : DNDArrayController <NSTableViewDelegate> {
|
2022-02-07 05:49:27 +00:00
|
|
|
IBOutlet PlaylistLoader *playlistLoader;
|
|
|
|
IBOutlet SpotlightWindowController *spotlightWindowController;
|
|
|
|
IBOutlet PlaybackController *playbackController;
|
2022-06-24 07:29:50 +00:00
|
|
|
IBOutlet AppController *appController;
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
NSValueTransformer *statusImageTransformer;
|
2021-01-30 23:14:08 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
NSMutableArray *shuffleList;
|
|
|
|
NSMutableArray *queueList;
|
2021-01-30 23:14:08 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
NSString *totalTime;
|
[Job Queue] Overhauled long action handling
Long actions, such as file opening, playlist loading, metadata loading
and refreshing, etc, are now handled through NSProgress. Additionally,
a new status bar change displays the progress of the task instead of
the total duration of the playlist. Finally, app quit is blocked by a
running task, and if the app is quit while a task is running, it will
be delayed until the task completes, at which time the app will
terminate cleanly.
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-15 08:01:45 +00:00
|
|
|
NSString *currentStatus;
|
2021-01-30 23:14:08 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
PlaylistEntry *currentEntry;
|
2021-01-30 23:14:08 +00:00
|
|
|
|
2022-02-10 05:04:17 +00:00
|
|
|
PlaylistEntry *nextEntryAfterDeleted;
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
NSUndoManager *undoManager;
|
[Job Queue] Overhauled long action handling
Long actions, such as file opening, playlist loading, metadata loading
and refreshing, etc, are now handled through NSProgress. Additionally,
a new status bar change displays the progress of the task instead of
the total duration of the playlist. Finally, app quit is blocked by a
running task, and if the app is quit while a task is running, it will
be delayed until the task completes, at which time the app will
terminate cleanly.
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-15 08:01:45 +00:00
|
|
|
|
|
|
|
BOOL observersRegistered;
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
@property(nonatomic, retain) PlaylistEntry *_Nullable currentEntry;
|
|
|
|
@property(retain) NSString *_Nullable totalTime;
|
[Job Queue] Overhauled long action handling
Long actions, such as file opening, playlist loading, metadata loading
and refreshing, etc, are now handled through NSProgress. Additionally,
a new status bar change displays the progress of the task instead of
the total duration of the playlist. Finally, app quit is blocked by a
running task, and if the app is quit while a task is running, it will
be delayed until the task completes, at which time the app will
terminate cleanly.
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-15 08:01:45 +00:00
|
|
|
@property(retain) NSString *_Nullable currentStatus;
|
2008-02-23 19:46:23 +00:00
|
|
|
|
2022-06-16 14:14:33 +00:00
|
|
|
@property(strong, nonatomic, readonly) NSPersistentContainer *_Nonnull persistentContainer;
|
|
|
|
@property(strong, nonatomic, readonly) NSMutableDictionary<NSString *, AlbumArtwork *> *_Nonnull persistentArtStorage;
|
|
|
|
|
2021-01-30 23:14:08 +00:00
|
|
|
// Private Methods
|
2022-06-16 14:14:33 +00:00
|
|
|
- (void)commitPersistentStore;
|
2006-04-13 18:40:23 +00:00
|
|
|
- (void)updateTotalTime;
|
2008-02-24 17:32:50 +00:00
|
|
|
- (void)updatePlaylistIndexes;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)stopAfterCurrent:(id _Nullable)sender;
|
2006-04-13 18:40:23 +00:00
|
|
|
|
2021-01-30 23:14:08 +00:00
|
|
|
// PUBLIC METHODS
|
2009-03-10 04:04:46 +00:00
|
|
|
- (void)setShuffle:(ShuffleMode)s;
|
|
|
|
- (ShuffleMode)shuffle;
|
2008-02-19 03:39:43 +00:00
|
|
|
- (void)setRepeat:(RepeatMode)r;
|
|
|
|
- (RepeatMode)repeat;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSArray *_Nullable)filterPlaylistOnAlbum:(NSString *_Nullable)album;
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (PlaylistEntry *_Nullable)getNextEntry:(PlaylistEntry *_Nullable)pe;
|
|
|
|
- (PlaylistEntry *_Nullable)getPrevEntry:(PlaylistEntry *_Nullable)pe;
|
2008-02-14 23:09:51 +00:00
|
|
|
|
2008-02-10 16:16:45 +00:00
|
|
|
/* Methods for undoing various actions */
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSUndoManager *_Nullable)undoManager;
|
2008-02-10 16:16:45 +00:00
|
|
|
|
2022-01-20 22:59:26 +00:00
|
|
|
- (IBAction)toggleShuffle:(id _Nullable)sender;
|
2008-02-19 04:02:05 +00:00
|
|
|
|
2022-01-20 22:59:26 +00:00
|
|
|
- (IBAction)toggleRepeat:(id _Nullable)sender;
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2022-01-20 22:59:26 +00:00
|
|
|
- (IBAction)randomizeList:(id _Nullable)sender;
|
2007-03-09 01:16:06 +00:00
|
|
|
|
2022-01-20 22:59:26 +00:00
|
|
|
- (IBAction)removeDuplicates:(id _Nullable)sender;
|
|
|
|
- (IBAction)removeDeadItems:(id _Nullable)sender;
|
2013-10-18 07:13:27 +00:00
|
|
|
|
2022-02-11 05:35:13 +00:00
|
|
|
- (IBAction)remove:(id _Nullable)sender;
|
|
|
|
- (IBAction)trash:(id _Nullable)sender;
|
|
|
|
|
2022-01-20 22:59:26 +00:00
|
|
|
- (IBAction)showEntryInFinder:(id _Nullable)sender;
|
|
|
|
- (IBAction)clearFilterPredicate:(id _Nullable)sender;
|
|
|
|
- (IBAction)clear:(id _Nullable)sender;
|
2007-02-18 22:27:55 +00:00
|
|
|
|
2008-11-21 15:14:23 +00:00
|
|
|
//- (IBAction)showTagEditor:(id)sender;
|
|
|
|
|
2008-02-16 16:13:21 +00:00
|
|
|
// Spotlight
|
2022-01-20 22:59:26 +00:00
|
|
|
- (IBAction)searchByArtist:(id _Nullable)sender;
|
|
|
|
- (IBAction)searchByAlbum:(id _Nullable)sender;
|
2008-02-16 16:13:21 +00:00
|
|
|
|
2021-01-30 23:14:08 +00:00
|
|
|
// FUN PLAYLIST MANAGEMENT STUFF!
|
2006-01-29 14:57:48 +00:00
|
|
|
- (BOOL)next;
|
|
|
|
- (BOOL)prev;
|
2006-01-20 15:22:03 +00:00
|
|
|
|
|
|
|
- (void)addShuffledListToBack;
|
|
|
|
- (void)addShuffledListToFront;
|
|
|
|
- (void)resetShuffleList;
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (PlaylistEntry *_Nullable)shuffledEntryAtIndex:(NSInteger)i;
|
|
|
|
- (PlaylistEntry *_Nullable)entryAtIndex:(NSInteger)i;
|
2007-03-09 01:16:06 +00:00
|
|
|
|
2008-05-09 21:24:49 +00:00
|
|
|
// Event inlets:
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)willInsertURLs:(NSArray *_Nullable)urls origin:(URLOrigin)origin;
|
|
|
|
- (void)didInsertURLs:(NSArray *_Nullable)urls origin:(URLOrigin)origin;
|
2008-05-09 21:24:49 +00:00
|
|
|
|
2008-02-21 07:30:28 +00:00
|
|
|
// queue methods
|
2022-01-20 22:59:26 +00:00
|
|
|
- (IBAction)toggleQueued:(id _Nullable)sender;
|
|
|
|
- (IBAction)emptyQueueList:(id _Nullable)sender;
|
2021-12-24 09:01:21 +00:00
|
|
|
- (void)emptyQueueListUnsynced;
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSMutableArray *_Nullable)queueList;
|
2008-02-21 07:30:28 +00:00
|
|
|
|
2022-06-19 09:05:26 +00:00
|
|
|
// internal methods for data store init
|
|
|
|
- (void)readQueueFromDataStore;
|
|
|
|
- (void)readShuffleListFromDataStore;
|
|
|
|
|
2022-06-21 07:01:07 +00:00
|
|
|
+ (NSPersistentContainer *_Nonnull)sharedPersistentContainer;
|
|
|
|
|
2021-07-03 22:32:13 +00:00
|
|
|
// reload metadata of selection
|
2022-01-20 22:59:26 +00:00
|
|
|
- (IBAction)reloadTags:(id _Nullable)sender;
|
2021-07-03 22:32:13 +00:00
|
|
|
|
2022-06-28 04:50:14 +00:00
|
|
|
// Reset playcount of selection
|
|
|
|
- (IBAction)resetPlaycounts:(id _Nullable)sender;
|
2022-06-28 08:55:30 +00:00
|
|
|
- (IBAction)removeRatings:(id _Nullable)sender;
|
2022-06-28 04:50:14 +00:00
|
|
|
|
2022-06-19 06:00:08 +00:00
|
|
|
// Play statistics
|
2022-06-20 10:35:29 +00:00
|
|
|
- (void)updatePlayCountForTrack:(PlaylistEntry *_Nonnull)pe;
|
2022-06-25 09:40:05 +00:00
|
|
|
- (void)firstSawTrack:(PlaylistEntry *_Nonnull)pe;
|
2022-06-19 06:00:08 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)moveObjectsInArrangedObjectsFromIndexes:(NSIndexSet *_Nullable)indexSet
|
2021-04-30 01:16:24 +00:00
|
|
|
toIndex:(NSUInteger)insertIndex;
|
2021-01-30 23:14:08 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)insertObjectsUnsynced:(NSArray *_Nullable)objects atArrangedObjectIndexes:(NSIndexSet *_Nullable)indexes;
|
2021-12-24 09:01:21 +00:00
|
|
|
|
2022-06-28 08:55:30 +00:00
|
|
|
- (void)tableView:(NSTableView *)view didClickRow:(NSInteger)clickedRow column:(NSInteger)clickedColumn atPoint:(NSPoint)cellPoint;
|
|
|
|
|
2022-06-29 05:58:13 +00:00
|
|
|
- (BOOL)pathSuggesterEmpty;
|
|
|
|
|
2005-06-02 18:16:43 +00:00
|
|
|
@end
|