BVPlaybackService

abstract class BVPlaybackService : MediaBrowserServiceCompat

Abstract base class for background playback services.

Providing PlayerConfig (choose one)

Option A (recommended): via ServicePlayerConnector.connect The config is passed in the startService Intent and used during initialization.

Option B: override onCreatePlayerConfig as a fallback Called when the Intent carries no config (e.g. on START_STICKY restart after system kill). Returns an empty PlayerConfig by default.

Required Manifest declaration

<service
android:name=".YourPlaybackService"
android:exported="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard
inner class PlaybackServiceBinder : Binder

Functions

Link copied to clipboard

Called when the app goes to background (from Activity.onStop, before disconnect).

Link copied to clipboard

Called when the app returns to the foreground (after connect succeeds in Activity.onStart).

Link copied to clipboard
@DrawableRes
abstract fun getNotificationSmallIconRes(): Int

Returns the small icon resource ID for the notification. Must be a monochrome white vector drawable.

Link copied to clipboard
fun loadMedia(mediaConfig: MediaConfig)
Link copied to clipboard
fun loadOfflineMedia(offlineMediaConfig: OfflineMediaConfig)
Link copied to clipboard
open override fun onBind(intent: Intent?): IBinder?

Supports dual binding:

Link copied to clipboard
open fun onCreateAnalyticsConfig(): AnalyticsConfig?

Fallback called when the Intent carries no AnalyticsConfig. Not required if the config is always provided via ServicePlayerConnector.connect.

Link copied to clipboard
open fun onCreateContentIntent(): PendingIntent?

Returns the PendingIntent to launch when the notification is tapped. Defaults to the app's launcher Activity; override to target a specific screen.

Link copied to clipboard

Fallback called when the Intent carries no PlayerConfig (e.g. after a system kill + START_STICKY restart). Not required if the config is always provided via ServicePlayerConnector.connect.

Link copied to clipboard
open override fun onDestroy()
Link copied to clipboard
open override fun onGetRoot(clientPackageName: String, clientUid: Int, rootHints: Bundle?): MediaBrowserServiceCompat.BrowserRoot?

Restricts MediaBrowser connections to clients within the same package by default. Override to allow external browsers (e.g. Android Auto).

Link copied to clipboard
open override fun onLoadChildren(parentId: String, result: MediaBrowserServiceCompat.Result<MutableList<MediaBrowserCompat.MediaItem>>)
Link copied to clipboard
open override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int
Link copied to clipboard
open override fun onTaskRemoved(rootIntent: Intent?)
Link copied to clipboard
fun updateMediaInfo(title: String, artist: String = "", artwork: ArtworkSource = ArtworkSource.None)

Updates what the notification and the media session show for the current media.