mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-29 22:29:29 +02:00
Remove: local library only item from playback and syncing media
This commit is contained in:
parent
1e0f1f329f
commit
7c6e098014
4 changed files with 6 additions and 21 deletions
|
@ -79,13 +79,8 @@ class PlaybackSession(
|
||||||
val progress
|
val progress
|
||||||
get() = currentTime / getTotalDuration()
|
get() = currentTime / getTotalDuration()
|
||||||
@get:JsonIgnore
|
@get:JsonIgnore
|
||||||
val isLocalLibraryItemOnly
|
|
||||||
get() = localLibraryItemId != "" && libraryItemId == null
|
|
||||||
@get:JsonIgnore
|
|
||||||
val mediaItemId
|
val mediaItemId
|
||||||
get() =
|
get() = if (episodeId.isNullOrEmpty()) libraryItemId ?: "" else "$libraryItemId-$episodeId"
|
||||||
if (isLocalLibraryItemOnly) localMediaProgressId
|
|
||||||
else if (episodeId.isNullOrEmpty()) libraryItemId ?: "" else "$libraryItemId-$episodeId"
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getCurrentTrackIndex(): Int {
|
fun getCurrentTrackIndex(): Int {
|
||||||
|
|
|
@ -114,20 +114,14 @@ object MediaEventManager {
|
||||||
|
|
||||||
private fun createMediaItemHistoryForSession(playbackSession: PlaybackSession): MediaItemHistory {
|
private fun createMediaItemHistoryForSession(playbackSession: PlaybackSession): MediaItemHistory {
|
||||||
Log.i(tag, "Creating new media item history for media \"${playbackSession.displayTitle}\"")
|
Log.i(tag, "Creating new media item history for media \"${playbackSession.displayTitle}\"")
|
||||||
val isLocalOnly = playbackSession.isLocalLibraryItemOnly
|
val libraryItemId = playbackSession.libraryItemId ?: ""
|
||||||
val libraryItemId =
|
val episodeId: String? = playbackSession.episodeId
|
||||||
if (isLocalOnly) playbackSession.localLibraryItemId
|
|
||||||
else playbackSession.libraryItemId ?: ""
|
|
||||||
val episodeId: String? =
|
|
||||||
if (isLocalOnly && playbackSession.localEpisodeId != null)
|
|
||||||
playbackSession.localEpisodeId
|
|
||||||
else playbackSession.episodeId
|
|
||||||
return MediaItemHistory(
|
return MediaItemHistory(
|
||||||
id = playbackSession.mediaItemId,
|
id = playbackSession.mediaItemId,
|
||||||
mediaDisplayTitle = playbackSession.displayTitle ?: "Unset",
|
mediaDisplayTitle = playbackSession.displayTitle ?: "Unset",
|
||||||
libraryItemId,
|
libraryItemId,
|
||||||
episodeId,
|
episodeId,
|
||||||
isLocalOnly,
|
false, // local-only items are not supported
|
||||||
playbackSession.serverConnectionConfigId,
|
playbackSession.serverConnectionConfigId,
|
||||||
playbackSession.serverAddress,
|
playbackSession.serverAddress,
|
||||||
playbackSession.userId,
|
playbackSession.userId,
|
||||||
|
|
|
@ -248,11 +248,7 @@ class MediaProgressSyncer(
|
||||||
|
|
||||||
// Save playback session to db (server linked sessions only)
|
// Save playback session to db (server linked sessions only)
|
||||||
// Sessions are removed once successfully synced with the server
|
// Sessions are removed once successfully synced with the server
|
||||||
currentPlaybackSession?.let {
|
currentPlaybackSession?.let { DeviceManager.dbManager.savePlaybackSession(it) }
|
||||||
if (!it.isLocalLibraryItemOnly) {
|
|
||||||
DeviceManager.dbManager.savePlaybackSession(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentIsLocal) {
|
if (currentIsLocal) {
|
||||||
// Save local progress sync
|
// Save local progress sync
|
||||||
|
|
|
@ -784,7 +784,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
if (currentPlaybackSession == null) return true
|
if (currentPlaybackSession == null) return true
|
||||||
|
|
||||||
mediaProgressSyncer.currentPlaybackSession?.let { playbackSession ->
|
mediaProgressSyncer.currentPlaybackSession?.let { playbackSession ->
|
||||||
if (!DeviceManager.checkConnectivity(ctx) || playbackSession.isLocalLibraryItemOnly) {
|
if (!DeviceManager.checkConnectivity(ctx)) {
|
||||||
return true // carry on
|
return true // carry on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue