Skip to content

Conversation

@nift4
Copy link
Contributor

@nift4 nift4 commented Jul 27, 2025

…pleBasePlayer

@nift4
Copy link
Contributor Author

nift4 commented Jul 27, 2025

to reproduce:

diff --git a/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt b/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt
index 134405ed9b..a805ab9533 100644
--- a/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt
+++ b/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt
@@ -203,7 +203,8 @@ class PlayerActivity : AppCompatActivity() {
           .setTextColor(ContextCompat.getColor(context, R.color.white))
         deleteButton.visibility = View.VISIBLE
         deleteButton.setOnClickListener {
-          controller.removeMediaItem(position)
+          //controller.removeMediaItem(position)
+          controller.setMediaItems(mutableListOf())
           updateCurrentPlaylistUI()
         }
       }
diff --git a/demos/session_service/src/main/java/androidx/media3/demo/session/DemoPlaybackService.kt b/demos/session_service/src/main/java/androidx/media3/demo/session/DemoPlaybackService.kt
index 66d68fd647..a69b524c0d 100644
--- a/demos/session_service/src/main/java/androidx/media3/demo/session/DemoPlaybackService.kt
+++ b/demos/session_service/src/main/java/androidx/media3/demo/session/DemoPlaybackService.kt
@@ -30,6 +30,7 @@ import androidx.datastore.core.DataStore
 import androidx.datastore.core.Serializer
 import androidx.datastore.dataStore
 import androidx.media3.common.AudioAttributes
+import androidx.media3.common.ForwardingSimpleBasePlayer
 import androidx.media3.common.Player
 import androidx.media3.common.listen
 import androidx.media3.common.util.UnstableApi
@@ -137,10 +138,10 @@ open class DemoPlaybackService : MediaLibraryService() {
   @OptIn(UnstableApi::class) // Player.listen
   private fun initializeSessionAndPlayer() {
     val player =
-      ExoPlayer.Builder(this)
+      ForwardingSimpleBasePlayer(ExoPlayer.Builder(this)
         .setAudioAttributes(AudioAttributes.DEFAULT, /* handleAudioFocus= */ true)
-        .build()
-    player.addAnalyticsListener(EventLogger())
+        .build())
+    //player.addAnalyticsListener(EventLogger())
     CoroutineScope(Dispatchers.Unconfined).launch {
       player.listen { events ->
         if (

@tonihei
Copy link
Collaborator

tonihei commented Jul 29, 2025

Thanks for reporting! I'll fix it in a slightly different way without merging this PR if that's okay?

@nift4
Copy link
Contributor Author

nift4 commented Jul 29, 2025

Sure! Thanks.

copybara-service bot pushed a commit that referenced this pull request Jul 30, 2025
Staying in STATE_BUFFERING or STATE_READY is not allowed
while the playlist is empty.

Issue: #2673
PiperOrigin-RevId: 788929128
@nift4 nift4 closed this Jul 30, 2025
@nift4 nift4 deleted the exoemptyfix branch July 30, 2025 18:13
nift4 pushed a commit to nift4/media that referenced this pull request Jul 30, 2025
Staying in STATE_BUFFERING or STATE_READY is not allowed
while the playlist is empty.

Issue: androidx#2673
PiperOrigin-RevId: 788929128
ghhccghk pushed a commit to ghhccghk/media that referenced this pull request Aug 11, 2025
Staying in STATE_BUFFERING or STATE_READY is not allowed
while the playlist is empty.

Issue: androidx#2673
PiperOrigin-RevId: 788929128
@androidx androidx locked and limited conversation to collaborators Sep 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants