mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
47 lines
1.2 KiB
Kotlin
47 lines
1.2 KiB
Kotlin
package net.torvald.terrarum.modulebasegame.console
|
|
|
|
import com.badlogic.gdx.Gdx
|
|
import com.badlogic.gdx.audio.Music
|
|
import net.torvald.terrarum.AssetCache
|
|
import net.torvald.terrarum.console.ConsoleCommand
|
|
import net.torvald.terrarum.console.Echo
|
|
|
|
/**
|
|
* Created by minjaesong on 2016-08-02.
|
|
*/
|
|
internal object MusicTest : ConsoleCommand {
|
|
|
|
var music: Music? = null
|
|
|
|
/**
|
|
* Args 0: command given
|
|
* Args 1: first argument
|
|
*
|
|
* e.g. in ```setav mass 74```, zeroth args will be ```setav```.
|
|
*/
|
|
override fun execute(args: Array<String>) {
|
|
if (args.size < 2) {
|
|
printUsage()
|
|
return
|
|
}
|
|
|
|
if (args[1] == "stop") {
|
|
music!!.stop()
|
|
return
|
|
}
|
|
|
|
val type = args[1].substringAfter('.').toUpperCase()
|
|
/*AudioLoader.getStreamingAudio(
|
|
type,
|
|
File("./assets/sounds/test/${args[1]}").absoluteFile.toURI().toURL()
|
|
).playAsMusic(1f, 1f, false)*/
|
|
|
|
music = Gdx.audio.newMusic(AssetCache.getFileHandle("sounds/test/${args[1]}"))
|
|
music!!.play()
|
|
}
|
|
|
|
override fun printUsage() {
|
|
Echo("Usage: musictest filename/in/res/sounds/test")
|
|
Echo("musictest stop to stop playback")
|
|
}
|
|
} |