mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 15:08:18 -07:00
feat: Sync offline/online playback when able (#431)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
15ac3566e2
commit
092836328f
42 changed files with 1002 additions and 497 deletions
|
|
@ -48,8 +48,42 @@ class UserData with UserDataMappable {
|
|||
);
|
||||
}
|
||||
|
||||
static dto.UserItemDataDto toDto(UserData? data) {
|
||||
if (data == null) {
|
||||
return const dto.UserItemDataDto();
|
||||
}
|
||||
return dto.UserItemDataDto(
|
||||
isFavorite: data.isFavourite,
|
||||
playCount: data.playCount,
|
||||
playbackPositionTicks: data.playbackPositionTicks,
|
||||
played: data.played,
|
||||
unplayedItemCount: data.unPlayedItemCount,
|
||||
lastPlayedDate: data.lastPlayed,
|
||||
playedPercentage: data.progress,
|
||||
);
|
||||
}
|
||||
|
||||
Duration get playBackPosition => Duration(milliseconds: playbackPositionTicks ~/ 10000);
|
||||
|
||||
// Returns null if unplayed with no progress
|
||||
static bool? isPlayed(Duration position, Duration totalDuration) {
|
||||
Duration startBuffer = totalDuration * 0.05;
|
||||
Duration endBuffer = totalDuration * 0.90;
|
||||
|
||||
Duration validStart = startBuffer;
|
||||
Duration validEnd = endBuffer;
|
||||
|
||||
if (position <= validStart) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (position <= validEnd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static UserData? determineLastUserData(List<UserData?> data) {
|
||||
return data.where((data) => data != null).reduce((a, b) {
|
||||
final aDate = a?.lastPlayed;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue