Playing a video and then minimizing the app causes a crash
Duplicate Check
- [x] I confirm I searched for existing reports and found no duplicates.
Describe the Bug
Fixed with new version
Working now thank you but having a new problem Playing a video and then minimizing the app causes a crash
I hv analysed this and it's , specifically related to the Media3 ExoPlayer library. The key issue is: IllegalStateException: Session ID must be unique. ID=com.mxavie.media3.service.SimpleMediaService.
Steps to Reproduce
- Key Error: java.lang.IllegalStateException: Session ID must be unique. ID=com.mxavie.media3.service.SimpleMediaService
- Fix for the Code: In SimpleMediaService.java (or SimpleMediaService.kt), ensure the Session ID is dynamic. Example: kotlin val sessionId = "media_session_${System.currentTimeMillis()}" // Unique ID val mediaSession = MediaSession.Builder(context, player) .setSessionId(sessionId) .build()
- Release the Media Session Properly: Add this to onDestroy(): kotlin override fun onDestroy() { mediaSession?.player?.release() mediaSession?.release() mediaSession = null super.onDestroy() }
- Update the AndroidManifest.xml:
Ensure the service is declared like this:
xml
- Test for Edge Cases: • Rapid app restarts (open/close the app multiple times quickly). • Background/foreground transitions (minimize the app while media is playing).
Hope this is helpful. 👆
Expected Behavior
The app should handle media playback without crashes, duplicate sessions, or resource leaks, ensuring a smooth and stable experience.
The SimpleMediaService should initialize and run smoothly without throwing IllegalStateException.
The app should never create multiple instances of SimpleMediaService simultaneously.
Lastly The app should recover gracefully from interruptions example incoming calls, app switches.
App Version
1.2.1
Android Version
Android 13
Device Model
Samsung a12
Custom ROM
- [ ] I am using a custom ROM
Custom ROM Name (if applicable)
No response
Screenshots (optional)
Log / Error Details
No response
Please update to the latest release v2.2.0, since 1.2.1 is several versions behind. If minimizing during video playback still crashes there, please attach the full crash log. Thanks for the analysis: the "Session ID must be unique" crash looks related to the open report #2399.
Automatic reply — the maintainer may follow up.