Comments (4)
You start the MediaSessionService
by building a MediaController
that then binds to the service.
The documentation section about the Service lifecycle explains how to stop the service.
from media.
Hello @marcbaechinger
- In My App I'm not using MediaController so I think this won't bind to the Service.
- As Document Suggested I'm clearing all instance when onDestroy is Triggered
fun stopService() {
mediaSession.run {
player.stop()
player.release()
release()
}
stopSelf()
}
override fun onDestroy() {
stopForeGround()
hideNotification()
super.onDestroy()
}
private fun stopForeGround() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
stopForeground(STOP_FOREGROUND_REMOVE)
} else {
stopForeground(true)
}
}
fun hideNotification() {
playerNotificationManager?.setPlayer(null)
playerNotificationManager= null
}
from media.
The intended use of MediaSessionService
is to be started with a controller and to use the controller to control playback. If based on your experience you choose to do your own thing this is fine, but I don't think we can extensively support you with this endeavor I'm afraid.
I'd recommend using the MediaSessionService
with a controller. But surely, that decisions is yours.
The MediaSessionService
implementation aims to make things easier for users that don't want to build their own service and hence don't need to read through the extensive foreground service documentation. Users that want to/have to read this documentation find that stopSelf
is a no-op in the case the service is still running in the foreground. So you'd have to call stopForeGround()
before calling stopSelf()
?
When not requiring a controller, I think I'd just create my own Service
implementation and refrain from using MediaSessionService
. This may be easier than bending MediaSessionService
your way. Certainly we are convinced that using MediaSessionService
in the intended way is the easiest approach and benefits developers that want to build a media app.
from media.
Hello @marcbaechinger
I Got Your Point It's Best to use MediaController when the service is MediaSessionService may be I will looks in to this, But Once MediaSessionService is Started as Normal Service with startForeGroundService(ServiceName) In OnStartCommand I am pushing PlayerNotificationManager with startForeground(NotificationConstants.NOTIFICATION_ID, notification)
Once User is Closing the App From OnDestroy I'm calling StopService(Service) where I Clear All Instance and stopForegound like private fun stopForeGround() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
stopForeground(STOP_FOREGROUND_REMOVE)
} else {
stopForeground(true)
}
}
After This I'm calling **stopSelf()** Notification was cleared But Service is Not Destroying Any Suggestions on This Would Help me lot, Thank You!!
from media.
Related Issues (20)
- Exoplayer misinterprets RTSP streams audioInputFormat as mp4a.40.1 instead of mp4a.40.2 HOT 1
- ExoPlayer clarification on DASH Byte-Range request against Player Buffer params' adjustments
- Unable to style default `SubtitleView` of the Media3 ExoPlayer HOT 3
- DefaultDrmSession should handle when key is already available (getKeyRequest() -> REQUEST_TYPE_NONE) HOT 4
- Support for playing Kotlin Multiplatform resources HOT 13
- HLS playback crash on Android 6 and below. HOT 2
- AGP 8.3.0 and newer crash: IllegalAccessError: Illegal class access: 'androidx.media3.session.MediaSessionStub' attempting to access 'com.google.common.util.concurrent.ImmediateFuture' HOT 11
- Media3 Exoplayer subtitle font size increase HOT 2
- Stall in ExoPlayer when EventStream falls out of window and is removed from the DASH manifest
- Sound disappears when custom equalizer is enabled
- Playback Error on Image Track (IllegalArgumentException: x + width must be <= bitmap.width()) HOT 1
- Multiple DRM protection levels in DASH stream with low DRM protection level on device HOT 7
- Captions can't be turned on using Google Assistant HOT 3
- Support for setting the start and end times of playback in TextOverlay. HOT 4
- Media Controllers — Slot reservation
- PlayBack Error on ExoPlayer HOT 2
- Is it possible to trim an EditedMediaItemSequence to a specified number of seconds? HOT 3
- Multiple devices achieve synchronous playback of local videos (the same video) HOT 1
- DASH manifest default_KID parameter HOT 3
- ExoPlayer Custom Renderer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from media.