I’m excited to announce the release of HXAudioPlayer 4.0.0, the latest major update to this Android audio playback library.
HXAudioPlayer is an Android library designed to make audio playback easier to implement by wrapping Android’s MediaPlayer and SoundPool APIs behind a simpler interface. It was originally built for games and game-oriented Android apps, where apps often need to manage both background music and short sound effects without manually handling the complexity of multiple MediaPlayer and SoundPool instances.
The library provides a straightforward way to play, pause, resume, loop, and manage music and sound effects with less boilerplate. It is currently used in several Y-Corner Android apps, including Dragon Geo, Cid’s Aerial Views, Chrono Maps, Robot Master Database, and Map of the Nocturne.
Version 4.0.0 is the first major update since v3.3.1, which was last updated in May 2018. This release modernizes the library for newer Android versions, adds full support for Android 17 / API 37, and removes legacy compatibility support for API 9–20, including Android 2.3 through Android 4.4.
The latest release and full changelog are available here: https://github.com/huhx0015/HXAudioPlayer/releases/tag/v4.0.0
The HXAudioPlayer repository is available here: https://github.com/huhx0015/HXAudioPlayer
Migrating from HXAudioPlayer 3.x to 4.0.0
HXAudioPlayer 4.0.0 is a major release that modernizes the library for current Android versions. Most existing music and sound playback APIs remain familiar, but there are a few important migration notes.
1. Minimum Android Version
HXAudioPlayer now requires Android 5.0 Lollipop / API 21 or higher.
Support has been removed for:
- Android 2.3 Gingerbread
- Android 3.x Honeycomb
- Android 4.0 Ice Cream Sandwich
- Android 4.1–4.3 Jelly Bean
- Android 4.4 KitKat
If your app still needs to support API 9–20, you should remain on the latest HXAudioPlayer 3.x release.
2. Remote Audio Playback
For apps streaming audio from remote URLs, prefer HTTPS.
Because modern Android target SDK behavior blocks cleartext traffic by default, http:// URLs may fail unless cleartext traffic is explicitly enabled. If HTTP is required, use a scoped networkSecurityConfig when possible instead of enabling cleartext traffic globally.
3. Legacy SoundPool Compatibility APIs
A few older compatibility APIs remain, but should no longer be relied on for normal usage:
HXSound.engines(2);
HXSound.reinitialize(context);
HXSound.engines(int) is now ignored on API 21+, and HXSound.reinitialize(Context) is deprecated except for manual reset scenarios.
4. Threading Changes
Music playback setup now runs through serialized background executors, making playback setup safer and less likely to block the main thread.
Most existing call sites do not need to change. However, if your app assumes playback setup happens immediately after calling play() or resume(), update that logic to rely on listener callbacks such as onMusicPrepared.
5. Optional Error Handling
HXMusicListener now includes an optional error callback:
@Override
public void onMusicError(HXMusicItem music, int what, int extra) {
// Optional: monitor MediaPlayer failures.
}
Existing listener implementations should continue to work because this callback has a default implementation.
6. New Convenience APIs
Builder-style playback still works, but v4.0.0 adds simpler helper methods:
HXMusic.play(context, R.raw.my_song);
HXMusic.play(context, R.raw.my_song, true);
HXMusic.play(context, “https://example.com/song.mp3”);
HXMusic.playGaplessLoop(context, R.raw.my_song);
HXSound.play(context, R.raw.my_sound);
HXSound.play(context, R.raw.my_sound, true);
These are optional shortcuts, so you can migrate gradually without rewriting existing builder-based playback code.
7. Position Values Use Milliseconds
HXMusicBuilder.at(int) expects a value in milliseconds.
For example:
.at(5000) // Starts playback at 5 seconds.
If any older code was passing seconds instead of milliseconds, update those values during migration.
