Implemented pause on startup
parent
ee29955db0
commit
759aeab4fb
|
@ -284,7 +284,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
|
|||
|
||||
if (lastStatus != kCogStatusStopped && lastIndex >= 0)
|
||||
{
|
||||
[playbackController playEntryAtIndex:lastIndex];
|
||||
[playbackController playEntryAtIndex:lastIndex startPaused:(lastStatus == kCogStatusPaused)];
|
||||
[playbackController seek:[NSNumber numberWithDouble:[[NSUserDefaults standardUserDefaults] floatForKey:@"lastTrackPosition"]]];
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,9 @@ extern NSDictionary * makeRGInfo(PlaylistEntry *pe);
|
|||
- (void)audioFadeUp:(NSTimer *)audioTimer;
|
||||
|
||||
- (void)playEntryAtIndex:(int)i;
|
||||
- (void)playEntryAtIndex:(int)i startPaused:(BOOL)paused;
|
||||
- (void)playEntry:(PlaylistEntry *)pe;
|
||||
- (void)playEntry:(PlaylistEntry *)pe startPaused:(BOOL)paused;
|
||||
|
||||
// Playlist notifications
|
||||
- (void)playlistDidChange:(PlaylistController *)p;
|
||||
|
|
|
@ -104,10 +104,15 @@ NSString *CogPlaybackDidStopNotficiation = @"CogPlaybackDidStopNotficiation";
|
|||
|
||||
//called by double-clicking on table
|
||||
- (void)playEntryAtIndex:(int)i
|
||||
{
|
||||
[self playEntryAtIndex:i startPaused:NO];
|
||||
}
|
||||
|
||||
- (void)playEntryAtIndex:(int)i startPaused:(BOOL)paused
|
||||
{
|
||||
PlaylistEntry *pe = [playlistController entryAtIndex:i];
|
||||
|
||||
[self playEntry:pe];
|
||||
[self playEntry:pe startPaused:paused];
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,6 +142,11 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
|||
}
|
||||
|
||||
- (void)playEntry:(PlaylistEntry *)pe
|
||||
{
|
||||
[self playEntry:pe startPaused:NO];
|
||||
}
|
||||
|
||||
- (void)playEntry:(PlaylistEntry *)pe startPaused:(BOOL)paused
|
||||
{
|
||||
if (playbackStatus != kCogStatusStopped)
|
||||
[self stop:self];
|
||||
|
@ -154,7 +164,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
|||
[pe performSelectorOnMainThread:@selector(setMetadata:) withObject:[playlistLoader readEntryInfo:pe] waitUntilDone:YES];
|
||||
}
|
||||
|
||||
[audioPlayer play:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe)];
|
||||
[audioPlayer play:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe) startPaused:paused];
|
||||
}
|
||||
|
||||
- (IBAction)next:(id)sender
|
||||
|
@ -188,6 +198,8 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
|||
|
||||
[audioPlayer seekToTime:time];
|
||||
|
||||
[self setPosition:time];
|
||||
|
||||
[[playlistController currentEntry] setCurrentPosition:time];
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
BOOL outputLaunched;
|
||||
BOOL endOfInputReached;
|
||||
BOOL startedPaused;
|
||||
BOOL initialBufferFilled;
|
||||
}
|
||||
|
||||
- (id)init;
|
||||
|
@ -37,6 +39,7 @@
|
|||
|
||||
- (void)play:(NSURL *)url;
|
||||
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary*)rgi;
|
||||
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary*)rgi startPaused:(BOOL)paused;
|
||||
|
||||
- (void)stop;
|
||||
- (void)pause;
|
||||
|
|
|
@ -45,10 +45,15 @@
|
|||
|
||||
- (void)play:(NSURL *)url
|
||||
{
|
||||
[self play:url withUserInfo:nil withRGInfo:nil];
|
||||
[self play:url withUserInfo:nil withRGInfo:nil startPaused:NO];
|
||||
}
|
||||
|
||||
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi
|
||||
{
|
||||
[self play:url withUserInfo:userInfo withRGInfo:rgi startPaused:NO];
|
||||
}
|
||||
|
||||
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused
|
||||
{
|
||||
if (output)
|
||||
{
|
||||
|
@ -101,8 +106,13 @@
|
|||
[self setShouldContinue:YES];
|
||||
|
||||
outputLaunched = NO;
|
||||
startedPaused = paused;
|
||||
initialBufferFilled = NO;
|
||||
|
||||
[bufferChain launchThreads];
|
||||
|
||||
if (paused)
|
||||
[self setPlaybackStatus:kCogStatusPaused waitUntilDone:YES];
|
||||
}
|
||||
|
||||
- (void)stop
|
||||
|
@ -121,6 +131,13 @@
|
|||
|
||||
- (void)resume
|
||||
{
|
||||
if (startedPaused)
|
||||
{
|
||||
startedPaused = NO;
|
||||
if (initialBufferFilled)
|
||||
[self launchOutputThread];
|
||||
}
|
||||
|
||||
[output resume];
|
||||
|
||||
[self setPlaybackStatus:kCogStatusPlaying waitUntilDone:YES];
|
||||
|
@ -200,7 +217,8 @@
|
|||
|
||||
- (void)launchOutputThread
|
||||
{
|
||||
if (outputLaunched == NO) {
|
||||
initialBufferFilled = YES;
|
||||
if (outputLaunched == NO && startedPaused == NO) {
|
||||
[self setPlaybackStatus:kCogStatusPlaying];
|
||||
[output launchThread];
|
||||
outputLaunched = YES;
|
||||
|
|
|
@ -75,7 +75,6 @@ typedef enum {
|
|||
|
||||
- (IBAction)toggleRepeat:(id)sender;
|
||||
|
||||
- (IBAction)sortByPath;
|
||||
- (IBAction)randomizeList:(id)sender;
|
||||
|
||||
- (IBAction)showEntryInFinder:(id)sender;
|
||||
|
|
|
@ -299,7 +299,7 @@
|
|||
- (void)insertObjects:(NSArray *)objects atArrangedObjectIndexes:(NSIndexSet *)indexes
|
||||
{
|
||||
[[[self undoManager] prepareWithInvocationTarget:self] removeObjectsAtArrangedObjectIndexes:indexes];
|
||||
NSString *actionName = [NSString stringWithFormat:@"Adding %d entries", [objects count]];
|
||||
NSString *actionName = [NSString stringWithFormat:@"Adding %lu entries", (unsigned long)[objects count]];
|
||||
[[self undoManager] setActionName:actionName];
|
||||
|
||||
[super insertObjects:objects atArrangedObjectIndexes:indexes];
|
||||
|
@ -312,7 +312,7 @@
|
|||
{
|
||||
NSArray *objects = [[self content] objectsAtIndexes:indexes];
|
||||
[[[self undoManager] prepareWithInvocationTarget:self] insertObjects:objects atArrangedObjectIndexes:indexes];
|
||||
NSString *actionName = [NSString stringWithFormat:@"Removing %d entries", [indexes count]];
|
||||
NSString *actionName = [NSString stringWithFormat:@"Removing %lu entries", (unsigned long)[indexes count]];
|
||||
[[self undoManager] setActionName:actionName];
|
||||
|
||||
DLog(@"Removing indexes: %@", indexes);
|
||||
|
|
Loading…
Reference in New Issue