diff --git a/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt b/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt index cf2c032c..e7e418a2 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt @@ -59,6 +59,7 @@ class StateHistory { return getHistoryPosition(url) > duration * 0.7; } + private var _lastHistoryBroadcast = ""; fun updateHistoryPosition(liveObj: IPlatformVideo, index: DBHistory.Index, updateExisting: Boolean, position: Long = -1L, date: OffsetDateTime? = null, isUserAction: Boolean = false): Long { val pos = if(position < 0) 0 else position; val historyVideo = index.obj; @@ -82,19 +83,21 @@ class StateHistory { historyVideo.date = date ?: OffsetDateTime.now(); _historyDBStore.update(index.id!!, historyVideo); onHistoricVideoChanged.emit(liveObj, pos); - } - if(isUserAction) { - StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) { - if(StateSync.instance.hasAtLeastOneOnlineDevice()) { - Logger.i(TAG, "SyncHistory playback broadcasted (${liveObj.name}: ${position})"); - StateSync.instance.broadcastJsonData( - GJSyncOpcodes.syncHistory, - listOf(historyVideo) - ); - } - }; + val historyBroadcastSig = "${historyVideo.position}${historyVideo.video.id.value ?: historyVideo.video.url}" + if(isUserAction && _lastHistoryBroadcast != historyBroadcastSig) { + _lastHistoryBroadcast = historyBroadcastSig; + StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) { + if(StateSync.instance.hasAtLeastOneOnlineDevice()) { + Logger.i(TAG, "SyncHistory playback broadcasted (${liveObj.name}: ${position})"); + StateSync.instance.broadcastJsonData( + GJSyncOpcodes.syncHistory, + listOf(historyVideo) + ); + } + }; + } } return positionBefore; } diff --git a/app/src/stable/assets/sources/spotify b/app/src/stable/assets/sources/spotify index 946bc835..62e19e2e 160000 --- a/app/src/stable/assets/sources/spotify +++ b/app/src/stable/assets/sources/spotify @@ -1 +1 @@ -Subproject commit 946bc835e18d62a584de7150a05cebea7c832b51 +Subproject commit 62e19e2e61ac55ee0d6d836dc1953c5e2b6751b3 diff --git a/app/src/stable/assets/sources/youtube b/app/src/stable/assets/sources/youtube index e2d896ac..f018ca77 160000 --- a/app/src/stable/assets/sources/youtube +++ b/app/src/stable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit e2d896ac45357e85b88a8d1f0a1fc5f4b72bfcfa +Subproject commit f018ca772da6bfc287fa4ef767a4f13c601b52c4 diff --git a/app/src/unstable/assets/sources/spotify b/app/src/unstable/assets/sources/spotify index 946bc835..62e19e2e 160000 --- a/app/src/unstable/assets/sources/spotify +++ b/app/src/unstable/assets/sources/spotify @@ -1 +1 @@ -Subproject commit 946bc835e18d62a584de7150a05cebea7c832b51 +Subproject commit 62e19e2e61ac55ee0d6d836dc1953c5e2b6751b3 diff --git a/app/src/unstable/assets/sources/youtube b/app/src/unstable/assets/sources/youtube index e2d896ac..f018ca77 160000 --- a/app/src/unstable/assets/sources/youtube +++ b/app/src/unstable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit e2d896ac45357e85b88a8d1f0a1fc5f4b72bfcfa +Subproject commit f018ca772da6bfc287fa4ef767a4f13c601b52c4