MediaService - Foreground Service - Keeps playback active even when the app is running in the background.

MediaService
Foreground Service.
Keeps playback active even when the app is running in the background.


Retrieves title, artist, and album from audio files
Extracts album art


Android 13+: You will need to request notification permission.


StartService

Start the player service.

component_method (3)

It must be called before any operation.


StopService

Stop the player service.

component_method (4)

Frees up resources and removes the notification


NotificationAlbumArt

Update the notification with the album cover of the current song.

The default images should be in the app's assets.


NotificationContent

Set notification title and content.

The default images should be in the app's assets.


Source

Set the media source and retrieve its metadata.


GetAlbumArt

Get the album art for a song from the path specified in the Source function. If it doesn't exist, use an image from the assets. Returns the file path.


SongTitle

Get song title.

component_set_get


ArtistName

Get artist name.

component_set_get (1)


AlbumName

Get album name.

component_set_get (2)


v1.0 Nov 30, 2025.

HeadphoneControls.aia (2.2 MB)

joejsanz.joedevmediaservice.aix (15.4 KB)


JDK: 11
Minimum API Level: 21
Updated On: 2025-11-30T08:00:00Z

Built using: FAST-CLI v5.3.2-premium


Thanks.

2 Likes

Why?

This should always be left to the app developer, as only they know which audio files and paths should be accessed. Your test app doesn't require any storage permissions at all, and that's true for all Android versions.