[Android] Fix subtitle track save and restore
Nicolas Pomepuy
git at videolan.org
Fri Nov 13 07:31:03 CET 2020
vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Nov 10 14:33:34 2020 +0100| [14ebd1ce7a4bf4885f334f5fea387bfad869136a] | committer: Nicolas Pomepuy
Fix subtitle track save and restore
Fixes #1532
(cherry picked from commit ca4d4bc4b3c1e0831313e6e27fd21ff14d261d1e)
> https://code.videolan.org/videolan/vlc-android/commit/14ebd1ce7a4bf4885f334f5fea387bfad869136a
---
.../org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 8 +-------
.../videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt | 16 +++++++++++-----
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index c5c68fe5f..197448228 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -1224,6 +1224,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
addNextTrack = false
} else if (spuTrack != 0 || currentSpuTrack != -2) {
service.setSpuTrack(if (media.id == 0L) currentSpuTrack else spuTrack)
+ lastSpuTrack = -2
}
}
}
@@ -1529,13 +1530,6 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
optionsDelegate?.hide()
}
- @WorkerThread
- fun setSpuTrack(trackID: Int) {
- runOnMainThread(Runnable { service?.setSpuTrack(trackID) })
- val mw = medialibrary.findMedia(service?.currentMediaWrapper) ?: return
- if (mw.id != 0L) mw.setLongMeta(MediaWrapper.META_SUBTITLE_TRACK, trackID.toLong())
- }
-
private fun showNavMenu() {
if (menuIdx >= 0) service?.titleIdx = menuIdx
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index e99738cfc..dba6f380c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -31,6 +31,7 @@ import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Build
+import android.util.Log
import android.view.View
import android.view.WindowManager
import android.view.animation.AnimationUtils
@@ -58,9 +59,7 @@ import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.medialibrary.media.MediaWrapperImpl
import org.videolan.resources.AndroidDevices
import org.videolan.tools.*
-import org.videolan.vlc.PlaybackService
-import org.videolan.vlc.R
-import org.videolan.vlc.RendererDelegate
+import org.videolan.vlc.*
import org.videolan.vlc.databinding.PlayerHudBinding
import org.videolan.vlc.databinding.PlayerHudRightBinding
import org.videolan.vlc.gui.audio.PlaylistAdapter
@@ -72,7 +71,6 @@ import org.videolan.vlc.gui.helpers.SwipeDragItemTouchHelperCallback
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.gui.helpers.UiTools.showVideoTrack
import org.videolan.vlc.gui.view.PlayerProgress
-import org.videolan.vlc.manageAbRepeatStep
import org.videolan.vlc.media.MediaUtils
import org.videolan.vlc.util.FileUtils
import org.videolan.vlc.viewmodels.PlaylistModel
@@ -143,7 +141,15 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
})
}
}
- VideoTracksDialog.TrackType.SPU -> player.service?.setSpuTrack(trackID)
+ VideoTracksDialog.TrackType.SPU -> {
+ player.service?.let { service ->
+ service.setSpuTrack(trackID)
+ runIO(Runnable {
+ val mw = player.medialibrary.findMedia(service.currentMediaWrapper)
+ if (mw != null && mw.id != 0L) mw.setLongMeta(MediaWrapper.META_SUBTITLE_TRACK, trackID.toLong())
+ })
+ }
+ }
VideoTracksDialog.TrackType.VIDEO -> {
player.service?.let { service ->
player.seek(service.time)
More information about the Android
mailing list