diff --git a/Application/AppController.m b/Application/AppController.m index d01225ee5..9b51bfe16 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -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"]]]; } } diff --git a/Application/PlaybackController.h b/Application/PlaybackController.h index fb5dd61c6..7516d0481 100644 --- a/Application/PlaybackController.h +++ b/Application/PlaybackController.h @@ -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; diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index 2dc3d2076..b40f9c1ac 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -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 diff --git a/Audio/AudioPlayer.h b/Audio/AudioPlayer.h index 8ee6a3525..90a68db80 100644 --- a/Audio/AudioPlayer.h +++ b/Audio/AudioPlayer.h @@ -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)decoder startPaused:(BOOL)paused; - (void)stop; diff --git a/Audio/AudioPlayer.m b/Audio/AudioPlayer.m index 323002e25..9ff3b6df3 100644 --- a/Audio/AudioPlayer.m +++ b/Audio/AudioPlayer.m @@ -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;