PillarboxMediaSessionService

PillarboxMediaSessionService implementation of MediaSessionService. It is the recommended way to make background playback for Android.

It handles only one MediaSession with one PillarboxExoPlayer.

Usage: Add these permissions inside your manifest:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

And add your PlaybackService to the application manifest as follow:

<service
android:name=".service.DemoMediaSessionService"
android:exported="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="androidx.media3.session.MediaSessionService" />
</intent-filter>
</service>

Use PillarboxMediaController.Builder to connect this Service to a PillarboxMediaController:

coroutineScope.launch() {
val mediaController: PillarboxPlayer = PillarboxMediaController.Builder(application, DemoMediaLibraryService::class.java)
doSomethingWith(mediaController)
}
...
mediaController.release() // when the MediaController is no longer needed.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val assets: AssetManager?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val baseContext: Context?
Link copied to clipboard
open val cacheDir: File?
Link copied to clipboard
Link copied to clipboard
open val codeCacheDir: File?
Link copied to clipboard
Link copied to clipboard
open val dataDir: File?
Link copied to clipboard
open val deviceId: Int
Link copied to clipboard
open val display: Display?
Link copied to clipboard
Link copied to clipboard
open val externalCacheDirs: Array<out File?>?
Link copied to clipboard
open val externalMediaDirs: Array<out File?>?
Link copied to clipboard
open val filesDir: File?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val mainLooper: Looper?
Link copied to clipboard
Link copied to clipboard
open val obbDir: File?
Link copied to clipboard
open val obbDirs: Array<out File?>?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val packageName: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Release on task removed

Link copied to clipboard
open val resources: Resources?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val wallpaper: Drawable?

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun checkCallingUriPermission(p0: Uri?, p1: Int): Int
Link copied to clipboard
Link copied to clipboard
open fun checkContentUriPermissionFull(p0: Uri, p1: Int, p2: Int, p3: Int): Int
Link copied to clipboard
open fun checkPermission(p0: String, p1: Int, p2: Int): Int
Link copied to clipboard
Link copied to clipboard
open fun checkUriPermission(p0: Uri?, p1: Int, p2: Int, p3: Int): Int
open fun checkUriPermission(p0: Uri?, p1: String?, p2: String?, p3: Int, p4: Int, p5: Int): Int
Link copied to clipboard
open fun checkUriPermissions(p0: List<Uri?>, p1: Int, p2: Int, p3: Int): IntArray
Link copied to clipboard
Link copied to clipboard
open fun clearWallpaper()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun createPackageContext(p0: String?, p1: Int): Context?
Link copied to clipboard
open fun createWindowContext(p0: Int, p1: Bundle?): Context
open fun createWindowContext(p0: Display, p1: Int, p2: Bundle?): Context
Link copied to clipboard
open fun databaseList(): Array<out String?>?
Link copied to clipboard
open fun deleteDatabase(p0: String?): Boolean
Link copied to clipboard
open fun deleteFile(p0: String?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun enforceCallingUriPermission(p0: Uri?, p1: Int, p2: String?)
Link copied to clipboard
open fun enforcePermission(p0: String, p1: Int, p2: Int, p3: String?)
Link copied to clipboard
open fun enforceUriPermission(p0: Uri?, p1: Int, p2: Int, p3: Int, p4: String?)
open fun enforceUriPermission(p0: Uri?, p1: String?, p2: String?, p3: Int, p4: Int, p5: Int, p6: String?)
Link copied to clipboard
open fun fileList(): Array<out String?>?
Link copied to clipboard
fun getColor(p0: Int): Int
Link copied to clipboard
Link copied to clipboard
open fun getDatabasePath(p0: String?): File?
Link copied to clipboard
open fun getDir(p0: String?, p1: Int): File?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getExternalFilesDirs(p0: String?): Array<out File?>?
Link copied to clipboard
open fun getFileStreamPath(p0: String?): File?
Link copied to clipboard
Link copied to clipboard
fun getString(p0: Int): String
fun getString(p0: Int, vararg p1: Any?): String
Link copied to clipboard
fun <T : Any?> getSystemService(p0: Class<T?>): T?
open fun getSystemService(p0: String): Any?
Link copied to clipboard
open fun getSystemServiceName(p0: Class<*>): String?
Link copied to clipboard
Link copied to clipboard
open fun grantUriPermission(p0: String?, p1: Uri?, p2: Int)
Link copied to clipboard
Link copied to clipboard
open fun moveDatabaseFrom(p0: Context?, p1: String?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onCreate()
Link copied to clipboard
open override fun onDestroy()
Link copied to clipboard
open override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaSession?
Link copied to clipboard
open fun onLowMemory()
Link copied to clipboard
open fun onRebind(p0: Intent?)
Link copied to clipboard
open fun onStart(p0: Intent?, p1: Int)
Link copied to clipboard
open fun onStartCommand(@Nullable p0: Intent?, p1: Int, p2: Int): Int
Link copied to clipboard
open override fun onTaskRemoved(rootIntent: Intent?)

We choose to stop playback when user remove application from the tasks

Link copied to clipboard
open fun onTimeout(p0: Int)
open fun onTimeout(p0: Int, p1: Int)
Link copied to clipboard
open fun onTrimMemory(p0: Int)
Link copied to clipboard
open fun onUnbind(p0: Intent?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun peekWallpaper(): Drawable?
Link copied to clipboard
Link copied to clipboard
open fun release()

Release the player and the MediaSession. The mediaSession is set to null after this call

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun revokeUriPermission(p0: Uri?, p1: Int)
open fun revokeUriPermission(p0: String?, p1: Uri?, p2: Int)
Link copied to clipboard
open fun sendBroadcast(p0: Intent?)
open fun sendBroadcast(p0: Intent?, p1: String?)
open fun sendBroadcast(p0: Intent, p1: String?, p2: Bundle?)
Link copied to clipboard
open fun sendBroadcastAsUser(p0: Intent?, p1: UserHandle?, p2: String?)
Link copied to clipboard
open fun sendOrderedBroadcast(p0: Intent?, p1: String?)
open fun sendOrderedBroadcast(p0: Intent, p1: String?, p2: Bundle?)
open fun sendOrderedBroadcast(p0: Intent, p1: String?, p2: BroadcastReceiver?, p3: Handler?, p4: Int, p5: String?, p6: Bundle?)
open fun sendOrderedBroadcast(p0: Intent, p1: String?, p2: Bundle?, p3: BroadcastReceiver?, p4: Handler?, p5: Int, p6: String?, p7: Bundle?)
open fun sendOrderedBroadcast(p0: Intent, p1: String?, p2: String?, p3: BroadcastReceiver?, p4: Handler?, p5: Int, p6: String?, p7: Bundle?)
open fun sendOrderedBroadcast(p0: Intent, p1: Int, p2: String?, p3: String?, p4: BroadcastReceiver?, p5: Handler?, p6: String?, p7: Bundle?, p8: Bundle?)
Link copied to clipboard
open fun sendOrderedBroadcastAsUser(p0: Intent?, p1: UserHandle?, p2: String?, p3: BroadcastReceiver?, p4: Handler?, p5: Int, p6: String?, p7: Bundle?)
Link copied to clipboard
open fun sendStickyBroadcast(p0: Intent, p1: Bundle?)
Link copied to clipboard
Link copied to clipboard
open fun sendStickyOrderedBroadcast(p0: Intent?, p1: BroadcastReceiver?, p2: Handler?, p3: Int, p4: String?, p5: Bundle?)
Link copied to clipboard
Link copied to clipboard

Session activity use with mediaSession called when setPlayer

Link copied to clipboard
fun setPlayer(player: PillarboxExoPlayer, mediaSessionCallback: PillarboxMediaSession.Callback = PillarboxMediaSession.Callback.Default, sessionId: String? = null)

Set player to use with this Service.

Link copied to clipboard
open fun setTheme(p0: Int)
Link copied to clipboard
open fun setWallpaper(p0: Bitmap?)
open fun setWallpaper(p0: InputStream?)
Link copied to clipboard
open fun startActivities(p0: Array<out Intent?>?)
open fun startActivities(p0: Array<out Intent?>?, p1: Bundle?)
Link copied to clipboard
open fun startActivity(p0: Intent?)
open fun startActivity(p0: Intent?, p1: Bundle?)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun startIntentSender(p0: IntentSender?, p1: Intent?, p2: Int, p3: Int, p4: Int)
open fun startIntentSender(p0: IntentSender?, p1: Intent?, p2: Int, p3: Int, p4: Int, p5: Bundle?)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun stopSelf()
fun stopSelf(p0: Int)
Link copied to clipboard
Link copied to clipboard
open fun stopService(p0: Intent?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard