feat: play beats when no music is selected

This commit is contained in:
2026-06-03 18:39:18 +02:00
parent 83dea946c3
commit 80ee56dfe8
2 changed files with 4 additions and 1 deletions

View File

@@ -486,7 +486,8 @@ void PlaybackEngine::playMusic(int fd, long long offset, long long length) {
closeMusicFile(); closeMusicFile();
} }
android_fd = fd; android_fd = fd;
musicFile.reset(mp3file_open_fd(android_fd, offset, length, 0)); if(fd != 0)
musicFile.reset(mp3file_open_fd(android_fd, offset, length, 0));
if(musicFile) { if(musicFile) {
timeRatio.store(((double) playbackRate.load()) / ((double) musicFile->rate)); timeRatio.store(((double) playbackRate.load()) / ((double) musicFile->rate));
haveTimeRatio.store(true); haveTimeRatio.store(true);

View File

@@ -105,6 +105,8 @@ public class LstForegroundService extends Service implements SensorEventListener
try { try {
if(contentUri != null) { if(contentUri != null) {
PlaybackEngine.playMusic(uriToFd(contentUri), this, R.raw.track_beat); PlaybackEngine.playMusic(uriToFd(contentUri), this, R.raw.track_beat);
} else {
PlaybackEngine.playMusic(0, this, R.raw.track_beat);
} }
} catch (IOException e) { } catch (IOException e) {
// TODO proper error handling // TODO proper error handling