2005-06-02 14:16:43 -04:00
|
|
|
//
|
|
|
|
// PlaylistController.h
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 3/18/05.
|
2005-07-02 17:02:06 -04:00
|
|
|
// Copyright 2005 Vincent Spader All rights reserved.
|
2005-06-02 14:16:43 -04:00
|
|
|
//
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
2022-06-16 10:14:33 -04:00
|
|
|
#import <CoreData/CoreData.h>
|
2008-02-10 13:16:45 -03:00
|
|
|
#import <Foundation/NSUndoManager.h>
|
2007-03-08 22:16:06 -03:00
|
|
|
|
2022-06-16 10:14:33 -04:00
|
|
|
#import "DNDArrayController.h"
|
|
|
|
|
|
|
|
@class AlbumArtwork;
|
|
|
|
|
2007-03-08 22:16:06 -03:00
|
|
|
@class PlaylistLoader;
|
|
|
|
@class PlaylistEntry;
|
2008-02-16 13:13:21 -03:00
|
|
|
@class SpotlightWindowController;
|
2008-05-09 17:24:49 -04:00
|
|
|
@class PlaybackController;
|
2022-06-24 03:29:50 -04:00
|
|
|
@class AppController;
|
2005-06-02 14:16:43 -04:00
|
|
|
|
2021-01-30 20:14:08 -03:00
|
|
|
typedef NS_ENUM(NSInteger, RepeatMode) {
|
2022-02-07 02:49:27 -03:00
|
|
|
RepeatModeNoRepeat = 0,
|
|
|
|
RepeatModeRepeatOne,
|
|
|
|
RepeatModeRepeatAlbum,
|
|
|
|
RepeatModeRepeatAll
|
2021-01-30 20:14:08 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline BOOL IsRepeatOneSet() {
|
2022-02-07 02:49:27 -03:00
|
|
|
return [[NSUserDefaults standardUserDefaults] integerForKey:@"repeat"] == RepeatModeRepeatOne;
|
2014-02-14 02:16:18 -03:00
|
|
|
}
|
|
|
|
|
2022-02-07 02:49:27 -03:00
|
|
|
typedef enum { ShuffleOff = 0,
|
|
|
|
ShuffleAlbums,
|
|
|
|
ShuffleAll } ShuffleMode;
|
2021-01-30 20:14:08 -03:00
|
|
|
|
|
|
|
typedef NS_ENUM(NSInteger, URLOrigin) {
|
2022-02-07 02:49:27 -03:00
|
|
|
URLOriginInternal = 0,
|
|
|
|
URLOriginExternal
|
2021-01-30 20:14:08 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
@interface PlaylistController : DNDArrayController <NSTableViewDelegate> {
|
2022-02-07 02:49:27 -03:00
|
|
|
IBOutlet PlaylistLoader *playlistLoader;
|
|
|
|
IBOutlet SpotlightWindowController *spotlightWindowController;
|
|
|
|
IBOutlet PlaybackController *playbackController;
|
2022-06-24 03:29:50 -04:00
|
|
|
IBOutlet AppController *appController;
|
2022-02-07 02:49:27 -03:00
|
|
|
|
|
|
|
NSValueTransformer *statusImageTransformer;
|
2021-01-30 20:14:08 -03:00
|
|
|
|
2022-02-07 02:49:27 -03:00
|
|
|
NSMutableArray *shuffleList;
|
|
|
|
NSMutableArray *queueList;
|
2021-01-30 20:14:08 -03:00
|
|
|
|
2022-02-07 02:49:27 -03: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 04:01:45 -04:00
|
|
|
NSString *currentStatus;
|
2021-01-30 20:14:08 -03:00
|
|
|
|
2022-02-07 02:49:27 -03:00
|
|
|
PlaylistEntry *currentEntry;
|
2021-01-30 20:14:08 -03:00
|
|
|
|
2022-02-10 02:04:17 -03:00
|
|
|
PlaylistEntry *nextEntryAfterDeleted;
|
|
|
|
|
2022-02-07 02:49:27 -03: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 04:01:45 -04:00
|
|
|
|
|
|
|
BOOL observersRegistered;
|
2005-06-02 14:16:43 -04:00
|
|
|
}
|
|
|
|
|
2022-02-07 02:49:27 -03: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 04:01:45 -04:00
|
|
|
@property(retain) NSString *_Nullable currentStatus;
|
2008-02-23 16:46:23 -03:00
|
|
|
|
2022-06-16 10:14:33 -04:00
|
|
|
@property(strong, nonatomic, readonly) NSPersistentContainer *_Nonnull persistentContainer;
|
|
|
|
@property(strong, nonatomic, readonly) NSMutableDictionary<NSString *, AlbumArtwork *> *_Nonnull persistentArtStorage;
|
|
|
|
|
2021-01-30 20:14:08 -03:00
|
|
|
// Private Methods
|
2022-06-16 10:14:33 -04:00
|
|
|
- (void)commitPersistentStore;
|
2006-04-13 14:40:23 -04:00
|
|
|
- (void)updateTotalTime;
|
2008-02-24 14:32:50 -03:00
|
|
|
- (void)updatePlaylistIndexes;
|
2022-02-07 02:49:27 -03:00
|
|
|
- (IBAction)stopAfterCurrent:(id _Nullable)sender;
|
2006-04-13 14:40:23 -04:00
|
|
|
|
2021-01-30 20:14:08 -03:00
|
|
|
// PUBLIC METHODS
|
2009-03-10 01:04:46 -03:00
|
|
|
- (void)setShuffle:(ShuffleMode)s;
|
|
|
|
- (ShuffleMode)shuffle;
|
2008-02-19 00:39:43 -03:00
|
|
|
- (void)setRepeat:(RepeatMode)r;
|
|
|
|
- (RepeatMode)repeat;
|
2022-02-07 02:49:27 -03:00
|
|
|
- (NSArray *_Nullable)filterPlaylistOnAlbum:(NSString *_Nullable)album;
|
2005-06-02 14:16:43 -04:00
|
|
|
|
2022-02-07 02:49:27 -03:00
|
|
|
- (PlaylistEntry *_Nullable)getNextEntry:(PlaylistEntry *_Nullable)pe;
|
|
|
|
- (PlaylistEntry *_Nullable)getPrevEntry:(PlaylistEntry *_Nullable)pe;
|
2008-02-14 20:09:51 -03:00
|
|
|
|
2008-02-10 13:16:45 -03:00
|
|
|
/* Methods for undoing various actions */
|
2022-02-07 02:49:27 -03:00
|
|
|
- (NSUndoManager *_Nullable)undoManager;
|
2008-02-10 13:16:45 -03:00
|
|
|
|
2022-01-20 19:59:26 -03:00
|
|
|
- (IBAction)toggleShuffle:(id _Nullable)sender;
|
2008-02-19 01:02:05 -03:00
|
|
|
|
2022-01-20 19:59:26 -03:00
|
|
|
- (IBAction)toggleRepeat:(id _Nullable)sender;
|
2005-06-02 14:16:43 -04:00
|
|
|
|
2022-01-20 19:59:26 -03:00
|
|
|
- (IBAction)randomizeList:(id _Nullable)sender;
|
2007-03-08 22:16:06 -03:00
|
|
|
|
2022-01-20 19:59:26 -03:00
|
|
|
- (IBAction)removeDuplicates:(id _Nullable)sender;
|
|
|
|
- (IBAction)removeDeadItems:(id _Nullable)sender;
|
2013-10-18 04:13:27 -03:00
|
|
|
|
2022-02-11 02:35:13 -03:00
|
|
|
- (IBAction)remove:(id _Nullable)sender;
|
|
|
|
- (IBAction)trash:(id _Nullable)sender;
|
|
|
|
|
2022-01-20 19:59:26 -03:00
|
|
|
- (IBAction)showEntryInFinder:(id _Nullable)sender;
|
|
|
|
- (IBAction)clearFilterPredicate:(id _Nullable)sender;
|
|
|
|
- (IBAction)clear:(id _Nullable)sender;
|
2007-02-18 19:27:55 -03:00
|
|
|
|
2008-11-21 12:14:23 -03:00
|
|
|
//- (IBAction)showTagEditor:(id)sender;
|
|
|
|
|
2008-02-16 13:13:21 -03:00
|
|
|
// Spotlight
|
2022-01-20 19:59:26 -03:00
|
|
|
- (IBAction)searchByArtist:(id _Nullable)sender;
|
|
|
|
- (IBAction)searchByAlbum:(id _Nullable)sender;
|
2008-02-16 13:13:21 -03:00
|
|
|
|
2021-01-30 20:14:08 -03:00
|
|
|
// FUN PLAYLIST MANAGEMENT STUFF!
|
2006-01-29 11:57:48 -03:00
|
|
|
- (BOOL)next;
|
|
|
|
- (BOOL)prev;
|
2006-01-20 12:22:03 -03:00
|
|
|
|
|
|
|
- (void)addShuffledListToBack;
|
|
|
|
- (void)addShuffledListToFront;
|
|
|
|
- (void)resetShuffleList;
|
2005-06-02 14:16:43 -04:00
|
|
|
|
2022-02-07 02:49:27 -03:00
|
|
|
- (PlaylistEntry *_Nullable)shuffledEntryAtIndex:(NSInteger)i;
|
|
|
|
- (PlaylistEntry *_Nullable)entryAtIndex:(NSInteger)i;
|
2007-03-08 22:16:06 -03:00
|
|
|
|
2008-05-09 17:24:49 -04:00
|
|
|
// Event inlets:
|
2022-02-07 02:49:27 -03:00
|
|
|
- (void)willInsertURLs:(NSArray *_Nullable)urls origin:(URLOrigin)origin;
|
|
|
|
- (void)didInsertURLs:(NSArray *_Nullable)urls origin:(URLOrigin)origin;
|
2008-05-09 17:24:49 -04:00
|
|
|
|
2008-02-21 04:30:28 -03:00
|
|
|
// queue methods
|
2022-01-20 19:59:26 -03:00
|
|
|
- (IBAction)toggleQueued:(id _Nullable)sender;
|
|
|
|
- (IBAction)emptyQueueList:(id _Nullable)sender;
|
2021-12-24 06:01:21 -03:00
|
|
|
- (void)emptyQueueListUnsynced;
|
2022-02-07 02:49:27 -03:00
|
|
|
- (NSMutableArray *_Nullable)queueList;
|
2008-02-21 04:30:28 -03:00
|
|
|
|
2022-06-19 05:05:26 -04:00
|
|
|
// internal methods for data store init
|
|
|
|
- (void)readQueueFromDataStore;
|
|
|
|
- (void)readShuffleListFromDataStore;
|
|
|
|
|
2022-06-21 03:01:07 -04:00
|
|
|
+ (NSPersistentContainer *_Nonnull)sharedPersistentContainer;
|
|
|
|
|
2021-07-03 18:32:13 -04:00
|
|
|
// reload metadata of selection
|
2022-01-20 19:59:26 -03:00
|
|
|
- (IBAction)reloadTags:(id _Nullable)sender;
|
2021-07-03 18:32:13 -04:00
|
|
|
|
2022-06-28 00:50:14 -04:00
|
|
|
// Reset playcount of selection
|
|
|
|
- (IBAction)resetPlaycounts:(id _Nullable)sender;
|
|
|
|
|
2022-06-19 02:00:08 -04:00
|
|
|
// Play statistics
|
2022-06-20 06:35:29 -04:00
|
|
|
- (void)updatePlayCountForTrack:(PlaylistEntry *_Nonnull)pe;
|
2022-06-25 05:40:05 -04:00
|
|
|
- (void)firstSawTrack:(PlaylistEntry *_Nonnull)pe;
|
2022-06-19 02:00:08 -04:00
|
|
|
|
2022-02-07 02:49:27 -03:00
|
|
|
- (void)moveObjectsInArrangedObjectsFromIndexes:(NSIndexSet *_Nullable)indexSet
|
2021-04-29 21:16:24 -04:00
|
|
|
toIndex:(NSUInteger)insertIndex;
|
2021-01-30 20:14:08 -03:00
|
|
|
|
2022-02-07 02:49:27 -03:00
|
|
|
- (void)insertObjectsUnsynced:(NSArray *_Nullable)objects atArrangedObjectIndexes:(NSIndexSet *_Nullable)indexes;
|
2021-12-24 06:01:21 -03:00
|
|
|
|
2005-06-02 14:16:43 -04:00
|
|
|
@end
|