Move ExoPlayer out of the activity into a MediaSessionService so audio keeps playing when the app is backgrounded, the screen is off, or the task is swiped away. Media3 provides the media notification, lock-screen and headset controls, audio focus and noisy-headphone handling. The UI talks to the service through a MediaController-backed AudioPlayer and sends title, artist, album and artwork metadata for the notification. Add the Android 13 notification permission request, the media playback foreground service permissions, and wake mode for network streaming.
This commit is contained in:
1 parent
9cdbb3702e
commit
b8bbf8d07c
12 files changed
+232
-82
No files matched your search
@@ -2,6 +2,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -20,5 +24,14 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".PlaybackService"
|
||||
android:exported="true"
|
||||
android:foregroundServiceType="mediaPlayback">
|
||||
<intent-filter>
|
||||
<action android:name="androidx.media3.session.MediaSessionService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
</application>
|
||||
</manifest>
|
||||
Reference in new issue
Block a user