Play audio from URLs, local files and assets.
Play music with the MediaPlayer SDK.
StartService
Starts the foreground player service.
StopService
Stops the foreground player service.
- You can turn off the screen without entering Doze mode.
A foregroundService is being used.
NotificationAlbumArt
Get the song's cover art to be displayed in the notification.
- songPath: Path to the song.
- imageIfTherIsntOne: If there is no cover art embedded in the song, an image is set from the assets.
NotificationContent
Sets the title and content for the notification that is displayed while the service is running.
-
The
SetNotificationContent
block is optional, but defaults to these values:title:
Playing
content:
Audio playback in progress
Play
Play audio from application assets, local files, or remote URLs.
Example Usages:
- Playing a local file from external storage:
Play("/storage/emulated/0/Music/song.mp3");
- Playing a file from the web:
Play("https://www.example.com/path/to/song.mp3");
Repeat
Set the repeat mode.
repeatMode:
RepeatMode helper block with these options:- repeatAll
- repeatOne
- repeatOff
Shuffle
Set songs to shuffle mode.
Loop
Calling the function causes playback to loop for the time set in the start and end parameters.
start:
Start time in milliseconds.end:
End time in milliseconds.
The set song segment will not stop playing until you call theDisableLoop
function.
DisableLoop
Disable loop playback, the song will continue to play normally.
Previous
Go back to the previous song.
Shuffle mode does not apply here, the song will be returned to the index before the current one.
Next
Go to the next song.
Shuffle mode applies to Next if enabled.
Pause
Pauses the current audio playback.
Stop
Stop the media playback and release resources.
Resume
Resume the media from the last paused position without losing audio focus.
Volume
Sets the volume of the left and right channels of the media player.
Each channel can be configured separately.
Volume value:
0.0
Mute volume
1.0
Maximum volume
Default value: 0.5
GetMusicFiles
Set the type of audio file you want to get.
-
audioType:
"MP3"Input types:
MP3, AAC, WAV, OGG, AMR, FLAC, MIDI, MP4, M4A, MKA.
Setting All
will get all audio types.
GetPlaylist
Get the list of songs set in SetPlaylist.
PlaybackSpeed
Set the playback speed (0.5 to 2.0 recommended).
speed:
The number must be greater than 0.0.
Pitch
Adjust the MediaPlayer playback pitch.
- 1.0 is normal pitch, recommended: 0.5 to 2.0.
CurrentPosition
Get the current playback position of the media.
ConvertToMilliseconds
Convert minutes and seconds to milliseconds.
ConvertToMinutesAndSeconds
Convert milliseconds to minutes and seconds.
SeekTo
Seek to a specific position in milliseconds.
AlbumArt
Get the album art of a song stored on the device and save it as a file. If no album art exists, it uses an image from assets. Returns the file path.
SongsCount
Get the total number of songs in the playlist.
IsPlaying
Returns true if the media player is currently playing.
SongTitle
Get song title.
ArtistName
Get artist name.
AlbumName
Get album name.
TrackNumber
Get track number.
Year
Get year of release.
Genre
Get music genre.
Composer
Get composer name.
Size
Get file size in readable format.
Duration
Returns the duration of the current audio in milliseconds.
AudioSessionId
Get MediaPlayer Sessión ID.
- When playing audio, you are given a session ID, when you stop the audio, that ID is lost.
Pausing does not lose the ID.
Can use with an Equalizer extension I created separately.
CurrentSongIndex
Returns the index of the currently playing song in the playlist. Returns 0 if no song is playing.
AudioFocusLost
Triggered when audio focus is lost due to another player starting.
SetPlaylist
Event triggered when playlist of songs is complete.
MusicFilesRetrieved
Event triggered when audio files are retrieved from the device.
- Provides lists of:
paths, titles, artists, albums, durations, tracks, years, genres, composers, sizes, displayNames and bitRates.
MediaPlay
Triggered when media starts playing.
MediaPause
Triggered when media is paused.
MediaStop
Triggered when media playback is stopped.
MediaNext
Triggered when the Next function is called.
MediaPrevious
Triggered when the Previous function is called.
PlaybackComplete
Set playback speed for audio.
SongIndexChanged
Triggered when a new song starts
Update: v1.2 Ago 30, 2025.
-
AIX file size reduced: from
945.1 KB
to30.9 KB
. -
Some functions also had their names changed somewhat.
-
Events have been renamed, removing the
On
. -
Playback from Assets was failing; this has now been fixed. The Play function will also play from Assets, so the PlayFromAssets function is no longer necessary.
- These functions and events have been removed: GetAllAssetMusicFiles, PlayFromAssets, and OnAssetMusicFilesRetrieved.
-
The following properties have been added:
-
TrackNumber - Gets the track number
-
Year - Gets the year of release
-
Genre - Gets the music genre
-
Composer - Gets the composer's name
-
Size - Gets the file size
-
Player.aia (2.2 MB)
joejsanz.joedevplayer.aix (30.9 KB)
JDK: 11
Minimum API Level: 21
Updated On: 2025-08-30T07:00:00Z
Built using: FAST-CLI v4.3.1-premium
Thanks.