Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Fix sounds still playing
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislo27 committed Feb 19, 2017
1 parent ffa781d commit 3ab2590
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions core/src/ionium/registry/AssetRegistry.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ionium.registry;

import chrislo27.rhre.lazysound.LazySound;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
import com.badlogic.gdx.audio.Music;
Expand Down Expand Up @@ -51,6 +52,7 @@ public static AssetRegistry instance() {
private Texture missingTexture;

private Array<Sound> tempSoundArray;
private Array<LazySound> tempLazySoundArray;
private Array<Music> tempMusicArray;

private void onInstantiate() {
Expand Down Expand Up @@ -288,29 +290,56 @@ public void pauseAllSound() {
tempSoundArray = manager.getAll(Sound.class, new Array<Sound>());
}

if (tempLazySoundArray == null) {
tempLazySoundArray = manager.getAll(LazySound.class, new Array<>());
}

for (Sound s : tempSoundArray) {
s.pause();
}

for (LazySound s : tempLazySoundArray) {
if (s.isLoaded())
s.getSound().pause();
}
}

public void resumeAllSound() {
if (tempSoundArray == null) {
tempSoundArray = manager.getAll(Sound.class, new Array<Sound>());
}

if (tempLazySoundArray == null) {
tempLazySoundArray = manager.getAll(LazySound.class, new Array<>());
}

for (Sound s : tempSoundArray) {
s.resume();
}

for (LazySound s : tempLazySoundArray) {
if (s.isLoaded())
s.getSound().resume();
}
}

public void stopAllSound() {
if (tempSoundArray == null) {
tempSoundArray = manager.getAll(Sound.class, new Array<Sound>());
}

if (tempLazySoundArray == null) {
tempLazySoundArray = manager.getAll(LazySound.class, new Array<>());
}

for (Sound s : tempSoundArray) {
s.stop();
}

for (LazySound s : tempLazySoundArray) {
if (s.isLoaded())
s.getSound().stop();
}
}

public void pauseAllMusic() {
Expand Down

0 comments on commit 3ab2590

Please sign in to comment.