Skip to content

Commit

Permalink
Convert mp3 to WAV before playing to workaround pause issue with mp3
Browse files Browse the repository at this point in the history
  • Loading branch information
jobe-m committed Aug 6, 2024
1 parent 5be3349 commit 8dbdfe4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package korlibs.korge.fleks.assets

import korlibs.audio.sound.SoundChannel
import korlibs.audio.sound.readMusic
import korlibs.audio.format.*
import korlibs.audio.sound.*
import korlibs.datastructure.*
import korlibs.image.atlas.MutableAtlasUnit
import korlibs.image.bitmap.*
Expand Down Expand Up @@ -148,8 +148,10 @@ class AssetStore {

assetConfig.sounds.forEach { sound ->
val soundFile = resourcesVfs[assetConfig.folder + "/" + sound.value].readMusic()
val soundChannel = soundFile.play()
val soundChannel = soundFile.decode().toWav().readMusic().play() // -- convert to WAV
// val soundChannel = soundFile.play()
// val soundChannel = resourcesVfs[assetConfig.assetFolderName + "/" + sound.value].readSound().play()

soundChannel.pause()
sounds[sound.key] = Pair(type, soundChannel)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class SnapshotSerializerSystem(module: SerializersModule) : IntervalSystem(
world.systems.forEach { system ->
when (system) {
// Sound system needs special handling, because it has to stop all sounds which are playing
is SoundSystem -> system.soundEnabled = true // TODO keep sound playing for now -- gameRunning
// is SoundSystem -> system.soundEnabled = true // TODO keep sound playing for now -- gameRunning
is SoundSystem -> system.soundEnabled = gameRunning
else -> system.enabled = gameRunning
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SoundSystem : IteratingSystem(
if (soundEnabled) {
// if (soundComponent.isPlaying && soundChannel.paused) soundChannel.resume()
if (soundComponent.isPlaying) {
soundChannel.current = 10000.milliseconds
// soundChannel.current = 10000.milliseconds
soundChannel.resume()
println("SoundSystem: Resume sound '${soundComponent.name}'")
}
Expand Down

0 comments on commit 8dbdfe4

Please sign in to comment.