Made resume playback on startup so that seeking operation is entirely atomic with starting playback, so the new seeking behavior doesn't have the potential to crash the player
parent
1cc34ea7d4
commit
917b7457b6
|
@ -180,8 +180,7 @@ void* kAppControllerContext = &kAppControllerContext;
|
|||
|
||||
if (lastStatus != CogStatusStopped && lastIndex >= 0)
|
||||
{
|
||||
[playbackController playEntryAtIndex:lastIndex startPaused:(lastStatus == CogStatusPaused)];
|
||||
[playbackController seek:[NSNumber numberWithDouble:[[NSUserDefaults standardUserDefaults] floatForKey:@"lastTrackPosition"]]];
|
||||
[playbackController playEntryAtIndex:lastIndex startPaused:(lastStatus == CogStatusPaused) andSeekTo:[NSNumber numberWithDouble:[[NSUserDefaults standardUserDefaults] floatForKey:@"lastTrackPosition"]]];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,10 @@ extern NSDictionary * makeRGInfo(PlaylistEntry *pe);
|
|||
|
||||
- (void)playEntryAtIndex:(NSInteger)i;
|
||||
- (void)playEntryAtIndex:(NSInteger)i startPaused:(BOOL)paused;
|
||||
- (void)playEntryAtIndex:(NSInteger)i startPaused:(BOOL)paused andSeekTo:(id)offset;
|
||||
- (void)playEntry:(PlaylistEntry *)pe;
|
||||
- (void)playEntry:(PlaylistEntry *)pe startPaused:(BOOL)paused;
|
||||
- (void)playEntry:(PlaylistEntry *)pe startPaused:(BOOL)paused andSeekTo:(id)offset;
|
||||
|
||||
// Playlist notifications
|
||||
- (void)playlistDidChange:(PlaylistController *)p;
|
||||
|
|
|
@ -117,14 +117,21 @@ NSString *CogPlaybackDidStopNotficiation = @"CogPlaybackDidStopNotficiation";
|
|||
//called by double-clicking on table
|
||||
- (void)playEntryAtIndex:(NSInteger)i
|
||||
{
|
||||
[self playEntryAtIndex:i startPaused:NO];
|
||||
[self playEntryAtIndex:i startPaused:NO andSeekTo:[NSNumber numberWithDouble:0.0]];
|
||||
}
|
||||
|
||||
- (void)playEntryAtIndex:(NSInteger)i startPaused:(BOOL)paused
|
||||
{
|
||||
PlaylistEntry *pe = [playlistController entryAtIndex:i];
|
||||
|
||||
[self playEntry:pe startPaused:paused andSeekTo:[NSNumber numberWithDouble:0.0]];
|
||||
}
|
||||
|
||||
- (void)playEntryAtIndex:(NSInteger)i startPaused:(BOOL)paused andSeekTo:(id)offset
|
||||
{
|
||||
PlaylistEntry *pe = [playlistController entryAtIndex:i];
|
||||
|
||||
[self playEntry:pe startPaused:paused];
|
||||
[self playEntry:pe startPaused:paused andSeekTo:offset];
|
||||
}
|
||||
|
||||
|
||||
|
@ -155,10 +162,15 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
|||
|
||||
- (void)playEntry:(PlaylistEntry *)pe
|
||||
{
|
||||
[self playEntry:pe startPaused:NO];
|
||||
[self playEntry:pe startPaused:NO andSeekTo:[NSNumber numberWithDouble:0.0]];
|
||||
}
|
||||
|
||||
- (void)playEntry:(PlaylistEntry *)pe startPaused:(BOOL)paused
|
||||
{
|
||||
[self playEntry:pe startPaused:paused andSeekTo:[NSNumber numberWithDouble:0.0]];
|
||||
}
|
||||
|
||||
- (void)playEntry:(PlaylistEntry *)pe startPaused:(BOOL)paused andSeekTo:(id)offset
|
||||
{
|
||||
if (playbackStatus != CogStatusStopped && playbackStatus != CogStatusStopping)
|
||||
[self stop:self];
|
||||
|
@ -166,7 +178,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
|||
DLog(@"PLAYLIST CONTROLLER: %@", [playlistController class]);
|
||||
[playlistController setCurrentEntry:pe];
|
||||
|
||||
[self setPosition:0.0];
|
||||
[self setPosition:[offset doubleValue]];
|
||||
|
||||
if (pe == nil)
|
||||
return;
|
||||
|
@ -198,7 +210,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
|||
|
||||
[self sendMetaData];
|
||||
|
||||
[audioPlayer play:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe) startPaused:paused];
|
||||
[audioPlayer play:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe) startPaused:paused andSeekTo:[offset doubleValue]];
|
||||
}
|
||||
|
||||
- (IBAction)next:(id)sender
|
||||
|
|
|
@ -46,6 +46,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)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary*)rgi startPaused:(BOOL)paused andSeekTo:(double)time;
|
||||
- (void)play:(id<CogDecoder>)decoder startPaused:(BOOL)paused;
|
||||
|
||||
- (void)stop;
|
||||
|
|
|
@ -45,15 +45,20 @@
|
|||
|
||||
- (void)play:(NSURL *)url
|
||||
{
|
||||
[self play:url withUserInfo:nil withRGInfo:nil startPaused:NO];
|
||||
[self play:url withUserInfo:nil withRGInfo:nil startPaused:NO andSeekTo:0.0];
|
||||
}
|
||||
|
||||
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi
|
||||
{
|
||||
[self play:url withUserInfo:userInfo withRGInfo:rgi startPaused:NO];
|
||||
[self play:url withUserInfo:userInfo withRGInfo:rgi startPaused:NO andSeekTo:0.0];
|
||||
}
|
||||
|
||||
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused
|
||||
{
|
||||
[self play:url withUserInfo:userInfo withRGInfo:rgi startPaused:paused andSeekTo:0.0];
|
||||
}
|
||||
|
||||
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused andSeekTo:(double)time
|
||||
{
|
||||
if (output) {
|
||||
[output close];
|
||||
|
@ -109,6 +114,12 @@
|
|||
|
||||
[bufferChain setUserInfo:userInfo];
|
||||
|
||||
if (time > 0.0)
|
||||
{
|
||||
[output seek:time];
|
||||
[bufferChain seek:time];
|
||||
}
|
||||
|
||||
[self setShouldContinue:YES];
|
||||
|
||||
outputLaunched = NO;
|
||||
|
|
Loading…
Reference in New Issue