[Android] Disable subtitles tracks while casting

Nicolas Pomepuy git at videolan.org
Wed Jan 20 09:54:28 UTC 2021


vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jan 14 13:57:19 2021 +0100| [7cdb45f482dcf595a1ee7040fb3d75bd2c6ac5dc] | committer: Nicolas Pomepuy

Disable subtitles tracks while casting

(cherry picked from commit b8818c413f91a993e65521556b86bec276edf3c7)

> https://code.videolan.org/videolan/vlc-android/commit/7cdb45f482dcf595a1ee7040fb3d75bd2c6ac5dc
---

 application/resources/src/main/res/values/strings.xml      |  1 +
 .../vlc-android/res/layout/player_overlay_track_item.xml   |  1 +
 .../src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt  | 14 ++++++++++----
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index d9c0df5d0..376e4a27f 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -779,5 +779,6 @@
     <string name="audio_delay_global">Audio delay set to %s ms for all videos</string>
     <string name="warning_stream_speed">Increasing playback speed over 1 for streams may cause stuttering</string>
     <string name="go_to_folder">Browse parent</string>
+    <string name="no_sub_renderer">Subtitles are not yet supported while casting</string>
 
 </resources>
diff --git a/application/vlc-android/res/layout/player_overlay_track_item.xml b/application/vlc-android/res/layout/player_overlay_track_item.xml
index 18d6baed7..c8a41d195 100644
--- a/application/vlc-android/res/layout/player_overlay_track_item.xml
+++ b/application/vlc-android/res/layout/player_overlay_track_item.xml
@@ -43,6 +43,7 @@
                 android:layout_marginTop="24dp"
                 android:gravity="center_vertical"
                 android:text="@string/no_track"
+                android:textAlignment="center"
                 android:textColor="@color/white_transparent_50"
                 android:visibility="gone"
                 app:layout_constraintEnd_toEndOf="parent"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt
index 102ce2e5b..6c359bedc 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt
@@ -91,11 +91,17 @@ class VideoTracksDialog : VLCBottomSheetDialogFragment() {
                 binding.audioTracks.trackList.adapter = trackAdapter
             }
             playbackService.spuTracks?.let { trackList ->
-                val trackAdapter = TrackAdapter(trackList as Array<MediaPlayer.TrackDescription>, trackList.firstOrNull { it.id == playbackService.spuTrack })
-                trackAdapter.setOnTrackSelectedListener { track ->
-                    trackSelectionListener.invoke(track.id, TrackType.SPU)
+                if (!playbackService.hasRenderer()) {
+                    val trackAdapter = TrackAdapter(trackList as Array<MediaPlayer.TrackDescription>, trackList.firstOrNull { it.id == playbackService.spuTrack })
+                    trackAdapter.setOnTrackSelectedListener { track ->
+                        trackSelectionListener.invoke(track.id, TrackType.SPU)
+                    }
+                    binding.subtitleTracks.trackList.adapter = trackAdapter
+                } else {
+                    binding.subtitleTracks.emptyView.text = getString(R.string.no_sub_renderer)
+                    binding.subtitleTracks.emptyView.setVisible()
+                    binding.subtitleTracks.trackMore.setGone()
                 }
-                binding.subtitleTracks.trackList.adapter = trackAdapter
                 if (trackList.isEmpty()) binding.subtitleTracks.emptyView.setVisible()
             }
             if (playbackService.spuTracks == null) binding.subtitleTracks.emptyView.setVisible()



More information about the Android mailing list