hxaudio-player
HX Audio Player for music and sound playback. Use when implementing music playback, sound effects, HXMusic, HXSound, or audio in HXAudioPlayer. Library is in the hxaudio module.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
설치 방법 보기포함된 파일(1)
- SKILL.md3.9 KB
SKILL.md(원문)
설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
HX Audio Player
Use HX Audio Player for music and sound in HXAudioPlayer. The library is in the hxaudio module. Targets Android 5.0+ (API 21) and uses modern MediaPlayer/SoundPool initialization paths.
Audio files: Place in res/raw/ (e.g. res/raw/my_song.mp3 → R.raw.my_song).
Music Playback (HXMusic)
Play from resource:
HXMusic.music()
.load(R.raw.my_song_name) // [REQUIRED]
.title("My Awesome Song") // [OPTIONAL]
.artist("Mr. Anonymous") // [OPTIONAL]
.date("January 1, 1998") // [OPTIONAL]
.at(5000) // Start position (milliseconds)
.gapless(true) // Gapless loop playback
.looped(true) // Loop
.play(this); // [REQUIRED]
Shortcut helpers (optional):
HXMusic.play(this, R.raw.my_song_name); // Play once
HXMusic.play(this, R.raw.my_song_name, true); // Loop
HXMusic.playGaplessLoop(this, R.raw.my_song_name); // Gapless loop
Play from path/URL:
HXMusic.music()
.load("https://example.com/song.mp3")
.title("My Awesome Song")
.play(this);
Control:
HXMusic.pause()— PauseHXMusic.resume(this)— ResumeHXMusic.stop()— Stop allHXMusic.isPlaying()— BooleanHXMusic.getPosition()— Current position (milliseconds)HXMusic.setListener(this)— HXMusicListenerHXMusic.getStatus()— Status stringHXMusic.enable(true)— Enable/disableHXMusic.logging(true)— Log outputHXMusic.clear()— Clear when app is terminating
Optional error callback (HXMusicListener):
@Override
public void onMusicError(HXMusicItem music, int what, int extra) {
// Optional: monitor MediaPlayer failures for diagnostics/recovery logic.
}
Lifecycle (Activity/Fragment):
onPause()→HXMusic.pause()— Pause when backgroundedonResume()→HXMusic.resume(this)— Resume when foreground- App terminating →
HXMusic.clear()— Clean up inonDestroy()
Sound Playback (HXSound)
Play sound:
HXSound.sound()
.load(R.raw.my_sound_effect) // [REQUIRED]
.looped(true) // [OPTIONAL]
.play(this); // [REQUIRED]
Shortcut helpers (optional):
HXSound.play(this, R.raw.my_sound_effect); // Play once
HXSound.play(this, R.raw.my_sound_effect, true); // Loop
Control:
HXSound.pause()— Pause looping soundsHXSound.resume()— ResumeHXSound.load(soundResourceList, context)— Pre-load resourcesHXSound.engines(2)— Retained for compatibility, ignored on API 21+HXSound.enable(true)— Enable/disableHXSound.reinitialize(this)— Deprecated compatibility API for explicit SoundPool resetHXSound.logging(true)— Log outputHXSound.clear()— Clear when no longer needed
Module
Add dependency in build.gradle:
implementation project(':hxaudio')
Notes
- Min SDK:
hxaudiotargets API 21+; legacy Gingerbread/Honeycomb compatibility branches are removed. - Target SDK: Current integration targets API 37.
- Gapless:
.gapless(true)enables seamless loop behavior for looped tracks in the modern playback path. - Threading:
HXMusic.play()/resume()andHXSound.play()/load()/reinitialize()are dispatched on serialized background executors. - Network security: For URL playback, prefer
https://endpoints. On modern targets, cleartexthttp://is blocked unless explicitly enabled viausesCleartextTrafficor anetworkSecurityConfigexception. - Release: Call
HXMusic.clear()andHXSound.clear()inonDestroy()when audio is no longer needed.
리뷰
아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
댓글
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.