maxrave-dev / maxrave-dev/SimpMusic
Playing a video and then minimizing the app causes a crash
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 11.4k
- Forks
- 599
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 7
Description
Duplicate Check
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SimpleMediaService.java or SimpleMediaService.kt and the corresponding AndroidManifest.xml service declaration. Reproduce playback followed by minimizing on Android 13, then inspect MediaSession lifecycle and session-ID handling; done means the transition no longer crashes and rapid restarts and interruptions remain stable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100