Play position is stored every 10 seconds, and status is stored every time playback is started, paused, stopped, or seeked
parent
7fe67b1630
commit
3e72087a41
|
@ -37,6 +37,7 @@ extern NSDictionary * makeRGInfo(PlaylistEntry *pe);
|
||||||
|
|
||||||
CogStatus playbackStatus;
|
CogStatus playbackStatus;
|
||||||
double position;
|
double position;
|
||||||
|
double lastPosition;
|
||||||
BOOL seekable;
|
BOOL seekable;
|
||||||
BOOL fading;
|
BOOL fading;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,9 @@ NSString *CogPlaybackDidStopNotficiation = @"CogPlaybackDidStopNotficiation";
|
||||||
|
|
||||||
- (IBAction)pause:(id)sender
|
- (IBAction)pause:(id)sender
|
||||||
{
|
{
|
||||||
[audioPlayer pause];
|
[[NSUserDefaults standardUserDefaults] setInteger:CogStatusPaused forKey:@"lastPlaybackStatus"];
|
||||||
|
|
||||||
|
[audioPlayer pause];
|
||||||
[self setPlaybackStatus: CogStatusPaused];
|
[self setPlaybackStatus: CogStatusPaused];
|
||||||
|
|
||||||
[self sendMetaData];
|
[self sendMetaData];
|
||||||
|
@ -107,13 +109,17 @@ NSString *CogPlaybackDidStopNotficiation = @"CogPlaybackDidStopNotficiation";
|
||||||
|
|
||||||
- (IBAction)resume:(id)sender
|
- (IBAction)resume:(id)sender
|
||||||
{
|
{
|
||||||
[audioPlayer resume];
|
[[NSUserDefaults standardUserDefaults] setInteger:CogStatusPlaying forKey:@"lastPlaybackStatus"];
|
||||||
|
|
||||||
|
[audioPlayer resume];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)stop:(id)sender
|
- (IBAction)stop:(id)sender
|
||||||
{
|
{
|
||||||
[audioPlayer stop];
|
[[NSUserDefaults standardUserDefaults] setInteger:CogStatusStopped forKey:@"lastPlaybackStatus"];
|
||||||
|
|
||||||
|
[audioPlayer stop];
|
||||||
|
|
||||||
[self sendMetaData];
|
[self sendMetaData];
|
||||||
}
|
}
|
||||||
|
@ -181,6 +187,8 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
||||||
|
|
||||||
DLog(@"PLAYLIST CONTROLLER: %@", [playlistController class]);
|
DLog(@"PLAYLIST CONTROLLER: %@", [playlistController class]);
|
||||||
[playlistController setCurrentEntry:pe];
|
[playlistController setCurrentEntry:pe];
|
||||||
|
|
||||||
|
lastPosition = -1;
|
||||||
|
|
||||||
[self setPosition:[offset doubleValue]];
|
[self setPosition:[offset doubleValue]];
|
||||||
|
|
||||||
|
@ -236,7 +244,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
||||||
- (void)updatePosition:(id)sender
|
- (void)updatePosition:(id)sender
|
||||||
{
|
{
|
||||||
double pos = [audioPlayer amountPlayed];
|
double pos = [audioPlayer amountPlayed];
|
||||||
|
|
||||||
[self setPosition:pos];
|
[self setPosition:pos];
|
||||||
|
|
||||||
[[playlistController currentEntry] setCurrentPosition:pos];
|
[[playlistController currentEntry] setCurrentPosition:pos];
|
||||||
|
@ -644,6 +652,18 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
|
||||||
|
|
||||||
- (void)setPosition:(double)p
|
- (void)setPosition:(double)p
|
||||||
{
|
{
|
||||||
|
if (p == 0 || p < lastPosition || (p > lastPosition && (p - lastPosition) >= 10.0))
|
||||||
|
{
|
||||||
|
PlaylistEntry * pe = [playlistController currentEntry];
|
||||||
|
NSInteger lastTrackPlaying = [pe index];
|
||||||
|
|
||||||
|
[[NSUserDefaults standardUserDefaults] setInteger:CogStatusPlaying forKey:@"lastPlaybackStatus"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setInteger:lastTrackPlaying forKey:@"lastTrackPlaying"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setDouble:p forKey:@"lastTrackPosition"];
|
||||||
|
|
||||||
|
lastPosition = p;
|
||||||
|
}
|
||||||
|
|
||||||
position = p;
|
position = p;
|
||||||
|
|
||||||
[[playlistController currentEntry] setCurrentPosition:p];
|
[[playlistController currentEntry] setCurrentPosition:p];
|
||||||
|
|
Loading…
Reference in New Issue