[Android] Add "stop after this track" in the video play queue adapter

Nicolas Pomepuy git at videolan.org
Fri Oct 20 12:01:31 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Oct  9 08:45:36 2023 +0200| [51858085655562a0b53132574111e4919feccdde] | committer: Duncan McNamara

Add "stop after this track" in the video play queue adapter

Fixes #3003

> https://code.videolan.org/videolan/vlc-android/commit/51858085655562a0b53132574111e4919feccdde
---

 application/vlc-android/res/menu/video_playqueue_item.xml |  5 +++++
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/application/vlc-android/res/menu/video_playqueue_item.xml b/application/vlc-android/res/menu/video_playqueue_item.xml
index ee5f29febe..1d5a277f8f 100644
--- a/application/vlc-android/res/menu/video_playqueue_item.xml
+++ b/application/vlc-android/res/menu/video_playqueue_item.xml
@@ -8,4 +8,9 @@
             android:id="@+id/audio_player_set_song"
             android:title="@string/set_song"/>
     </group>
+    <item
+            android:id="@+id/stop_after"
+            android:title="@string/stop_after_this"
+            android:checkable="true"
+            android:checked="false"/>
 </menu>
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 9f9cc1977a..e3dd8b66ed 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
@@ -1726,11 +1726,20 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
     override fun onPopupMenu(view: View, position: Int, item: MediaWrapper?) {
         val popupMenu = PopupMenu(this, view)
         popupMenu.menuInflater.inflate(R.menu.video_playqueue_item, popupMenu.menu)
+        if (position == service?.playlistManager?.stopAfter) {
+            popupMenu.menu.findItem(R.id.stop_after).isChecked = true
+        }
 
         popupMenu.setOnMenuItemClickListener(PopupMenu.OnMenuItemClickListener { curentItem ->
-            if (curentItem.itemId == R.id.audio_player_mini_remove) service?.run {
-                remove(position)
-                return at OnMenuItemClickListener true
+            when (curentItem.itemId) {
+                R.id.audio_player_mini_remove -> service?.run {
+                    remove(position)
+                    return at OnMenuItemClickListener true
+                }
+                R.id.stop_after -> {
+                    playlistModel?.stopAfter(position)
+                    curentItem.isChecked = true
+                }
             }
             false
         })



More information about the Android mailing list