Skip to content

Commit

Permalink
Fix music
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Oct 18, 2024
1 parent 38ff9e2 commit c6c1f08
Showing 1 changed file with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public HowlMusic(FileHandle fileHandle) {
byte[] bytes = fileHandle.readBytes();
ArrayBufferViewWrapper data = TypedArrays.getTypedArray(bytes);
howl = Howl.create(data);
soundId = -1;
}

@Override
Expand All @@ -28,7 +29,9 @@ public void play() {

@Override
public void pause() {
howl.pause(soundId);
if(soundId != -1) {
howl.pause(soundId);
}
}

@Override
Expand All @@ -39,38 +42,55 @@ public void stop() {

@Override
public boolean isPlaying() {
return howl.isPlaying(soundId);
if(soundId != -1) {
return howl.isPlaying(soundId);
}
return false;
}

@Override
public void setLooping(boolean isLooping) {
howl.setLoop(isLooping, soundId);
if(soundId != -1) {
howl.setLoop(isLooping, soundId);
}
}

@Override
public boolean isLooping() {
return howl.getLoop(soundId);
if(soundId != -1) {
return howl.getLoop(soundId);
}
return false;
}

@Override
public void setVolume(float volume) {
howl.setVolume(volume, soundId);
if(soundId != -1) {
howl.setVolume(volume, soundId);
}
}

@Override
public float getVolume() {
return howl.getVolume(soundId);
if(soundId != -1) {
return howl.getVolume(soundId);
}
return 0f;
}

@Override
public void setPan(float pan, float volume) {
howl.setStereo(pan, soundId);
howl.setVolume(volume, soundId);
if(soundId != -1) {
howl.setStereo(pan, soundId);
howl.setVolume(volume, soundId);
}
}

@Override
public void setPosition(float position) {
howl.setSeek(position, soundId);
if(soundId != -1) {
howl.setSeek(position, soundId);
}
}

@Override
Expand Down

0 comments on commit c6c1f08

Please sign in to comment.