From ce66937429ee24d9b15a9fe69089be7e4891d892 Mon Sep 17 00:00:00 2001 From: Koen J Date: Tue, 10 Dec 2024 14:01:34 +0100 Subject: [PATCH] Offline playback toast now doesn't show more than once every 5 seconds. --- .../fragment/mainactivity/main/VideoDetailView.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt index 8ec9c29b..c90c1da6 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt @@ -1799,8 +1799,13 @@ class VideoDetailView : ConstraintLayout { private fun onSourceChanged(videoSource: IVideoSource?, audioSource: IAudioSource?, resume: Boolean){ Logger.i(TAG, "onSourceChanged(videoSource=$videoSource, audioSource=$audioSource, resume=$resume)") - if((videoSource == null || videoSource is LocalVideoSource) && (audioSource == null || audioSource is LocalAudioSource)) - UIDialogs.toast(context, context.getString(R.string.offline_playback), false); + if((videoSource == null || videoSource is LocalVideoSource) && (audioSource == null || audioSource is LocalAudioSource)) { + Logger.i(TAG, "Time since last offline playback toast: " + (System.currentTimeMillis() - _lastOfflinePlaybackToastTime).toString()) + if (System.currentTimeMillis() - _lastOfflinePlaybackToastTime > 5000) { + UIDialogs.toast(context, context.getString(R.string.offline_playback), false); + _lastOfflinePlaybackToastTime = System.currentTimeMillis() + } + } //If LiveStream, set to end if(videoSource is IDashManifestSource || videoSource is IHLSManifestSource) { if (video?.isLive == true) { @@ -3030,8 +3035,6 @@ class VideoDetailView : ConstraintLayout { const val TAG_MORE = "MORE"; private val _buttonPinStore = FragmentedStorage.get("videoPinnedButtons"); - - - + private var _lastOfflinePlaybackToastTime: Long = 0 } } \ No newline at end of file