Playback: Always remember last playing track
Select it on startup, and start playback at the last position if configured to do so. Also, if there is a bug and multiple tracks are marked for current, unmark them as usual, but also commit the changes. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
6b047c0acf
commit
f549465a4f
1 changed files with 4 additions and 6 deletions
|
@ -247,14 +247,11 @@ static BOOL consentLastEnabled = NO;
|
||||||
|
|
||||||
if(results && [results count] > 0) {
|
if(results && [results count] > 0) {
|
||||||
PlaylistEntry *pe = results[0];
|
PlaylistEntry *pe = results[0];
|
||||||
|
// Select this track
|
||||||
|
[playlistView selectRowIndexes:[NSIndexSet indexSetWithIndex:pe.index] byExtendingSelection:NO];
|
||||||
if([[NSUserDefaults standardUserDefaults] boolForKey:@"resumePlaybackOnStartup"]) {
|
if([[NSUserDefaults standardUserDefaults] boolForKey:@"resumePlaybackOnStartup"]) {
|
||||||
|
// And play it
|
||||||
[playbackController playEntryAtIndex:pe.index startPaused:(lastStatus == CogStatusPaused) andSeekTo:@(pe.currentPosition)];
|
[playbackController playEntryAtIndex:pe.index startPaused:(lastStatus == CogStatusPaused) andSeekTo:@(pe.currentPosition)];
|
||||||
} else {
|
|
||||||
pe.current = NO;
|
|
||||||
pe.stopAfter = NO;
|
|
||||||
pe.currentPosition = 0.0;
|
|
||||||
pe.countAdded = NO;
|
|
||||||
[playlistController commitPersistentStore];
|
|
||||||
}
|
}
|
||||||
// Bug fix
|
// Bug fix
|
||||||
if([results count] > 1) {
|
if([results count] > 1) {
|
||||||
|
@ -262,6 +259,7 @@ static BOOL consentLastEnabled = NO;
|
||||||
PlaylistEntry *pe = results[i];
|
PlaylistEntry *pe = results[i];
|
||||||
[pe setCurrent:NO];
|
[pe setCurrent:NO];
|
||||||
}
|
}
|
||||||
|
[playlistController commitPersistentStore];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue