[Play Count] Remember added count across sessions

Remember if play count was already tracked for the current file across
restarts, if resume playback after restart is enabled.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-20 19:13:33 -07:00
parent 2ce719c7fa
commit c89837c0f8
3 changed files with 8 additions and 1 deletions

View File

@ -217,7 +217,9 @@ BOOL kAppControllerShuttingDown = NO;
[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];
}
}

View File

@ -23,6 +23,7 @@
<attribute name="channelConfig" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="channels" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="codec" optional="YES" attributeType="String"/>
<attribute name="countAdded" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="cuesheet" optional="YES" attributeType="String"/>
<attribute name="current" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="currentPosition" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
@ -67,7 +68,7 @@
<elements>
<element name="AlbumArtwork" positionX="0" positionY="207" width="128" height="59"/>
<element name="PlayCount" positionX="-18" positionY="171" width="128" height="134"/>
<element name="PlaylistEntry" positionX="-36" positionY="9" width="128" height="704"/>
<element name="PlaylistEntry" positionX="-36" positionY="9" width="128" height="719"/>
<element name="SandboxToken" positionX="-18" positionY="171" width="128" height="59"/>
</elements>
</model>

View File

@ -246,6 +246,9 @@ static void *playlistControllerContext = &playlistControllerContext;
}
- (void)updatePlayCountForTrack:(PlaylistEntry *)pe {
if(pe.countAdded) return;
pe.countAdded = YES;
PlayCount *pc = pe.playCountItem;
if(pc) {
@ -1393,6 +1396,7 @@ static void *playlistControllerContext = &playlistControllerContext;
currentEntry.current = NO;
currentEntry.stopAfter = NO;
currentEntry.currentPosition = 0.0;
currentEntry.countAdded = NO;
}
if(pe) {