Google is committed to advancing racial equity for Black communities. See how.

MediaLibraryService

abstract class MediaLibraryService : MediaSessionService
kotlin.Any
   ↳ android.content.Context
   ↳ android.content.ContextWrapper
   ↳ android.app.Service
   ↳ androidx.media2.session.MediaSessionService
   ↳ androidx.media2.session.MediaLibraryService

Base class for media library services, which is the service containing MediaLibrarySession.

Media library services enable applications to browse media content provided by an application and ask the application to start playing it. They may also be used to control content that is already playing by way of a MediaSession.

When extending this class, also add the following to your AndroidManifest.xml.

<service android:name="component_name_of_your_implementation" >
    <intent-filter>
      <action android:name="androidx.media2.session.MediaLibraryService" />
    </intent-filter>
  </service>

You may also declare

android.media.browse.MediaBrowserService
for compatibility with android.support.v4.media.MediaBrowserCompat. This service can handle it automatically.

Summary

Nested classes

Contains information that the library service needs to send to the client.

Session for the MediaLibraryService.

Constants
static String

The Intent that must be declared as handled by the service.

Public constructors

Base class for media library services, which is the service containing MediaLibrarySession.

Public methods
open IBinder?
onBind(@NonNull intent: Intent)

abstract MediaLibraryService.MediaLibrarySession?
onGetSession(@NonNull controllerInfo: MediaSession.ControllerInfo)

Inherited functions

Constants

SERVICE_INTERFACE

static val SERVICE_INTERFACE: String

The Intent that must be declared as handled by the service.

Value: "androidx.media2.session.MediaLibraryService"

Public constructors

<init>

MediaLibraryService()

Base class for media library services, which is the service containing MediaLibrarySession.

Media library services enable applications to browse media content provided by an application and ask the application to start playing it. They may also be used to control content that is already playing by way of a MediaSession.

When extending this class, also add the following to your AndroidManifest.xml.

<service android:name="component_name_of_your_implementation" >
    <intent-filter>
      <action android:name="androidx.media2.session.MediaLibraryService" />
    </intent-filter>
  </service>

You may also declare

android.media.browse.MediaBrowserService
for compatibility with android.support.v4.media.MediaBrowserCompat. This service can handle it automatically.

Public methods

onBind

open fun onBind(@NonNull intent: Intent): IBinder?

onGetSession

@Nullable abstract fun onGetSession(@NonNull controllerInfo: MediaSession.ControllerInfo): MediaLibraryService.MediaLibrarySession?