Easter cleaning git
This commit is contained in:
commit
d0529bfadf
500 changed files with 116670 additions and 0 deletions
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.gdxapp4d.app.tosamp;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Deactivate;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
|
||||
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs;
|
||||
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog;
|
||||
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4DeskAppService;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4LocaleService;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection;
|
||||
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
|
||||
|
||||
@Component
|
||||
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public class TosAmpComponent {
|
||||
|
||||
@Reference
|
||||
private SystemGdxLog log;
|
||||
|
||||
@Reference
|
||||
private VrGem4DeskAppService deskAppService;
|
||||
|
||||
@Reference
|
||||
private SystemGdxBootArgs bootArgs;
|
||||
|
||||
@Reference
|
||||
private SystemWarpShip warpShip;
|
||||
|
||||
@Reference
|
||||
private VrGem4LocaleService localeService;
|
||||
|
||||
private final static String I18N_BUNDLE = "love.distributedrebirth.gdxapp4d.app.tosamp.Messages";
|
||||
private DeskAppLauncher launcher;
|
||||
|
||||
public TosAmpComponent() {
|
||||
}
|
||||
|
||||
private ResourceBundle createBundle() {
|
||||
return ResourceBundle.getBundle(I18N_BUNDLE, localeService.getTextLocale());
|
||||
}
|
||||
|
||||
@Activate
|
||||
void open(final BundleContext context) {
|
||||
log.debug(this, SystemGdxLog.ACTIVATE);
|
||||
launcher = new DeskAppLauncher(DeskAppMenuSection.MULTIMEDIA, "TosAmp", () -> new TosAmpDeskApp(createBundle(), bootArgs.getFileChooser(), context, warpShip));
|
||||
deskAppService.installDeskApp(launcher);
|
||||
}
|
||||
|
||||
@Deactivate
|
||||
void close() {
|
||||
log.debug(this, SystemGdxLog.DEACTIVATE);
|
||||
deskAppService.removeDeskApp(launcher);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.gdxapp4d.app.tosamp;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiSelectableFlags;
|
||||
import imgui.flag.ImGuiTableColumnFlags;
|
||||
import imgui.flag.ImGuiTableFlags;
|
||||
import love.distributedrebirth.gdxapp4d.app.tosamp.music.MusicManager;
|
||||
import love.distributedrebirth.gdxapp4d.app.tosamp.music.MusicSong;
|
||||
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.AbstractDeskApp;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppContourSection;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppRenderer;
|
||||
import net.spookygames.gdx.nativefilechooser.NativeFileChooser;
|
||||
import net.spookygames.gdx.nativefilechooser.NativeFileChooserCallback;
|
||||
import net.spookygames.gdx.nativefilechooser.NativeFileChooserConfiguration;
|
||||
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
|
||||
|
||||
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
|
||||
|
||||
private final ResourceBundle bundle;
|
||||
private final MusicManager music;
|
||||
private final NativeFileChooser fileChooser;
|
||||
private NativeFileChooserConfiguration fileChooserConfig;
|
||||
|
||||
public TosAmpDeskApp(ResourceBundle bundle, NativeFileChooser fileChooser, BundleContext context, SystemWarpShip warpShip) {
|
||||
this.bundle = bundle;
|
||||
this.fileChooser = fileChooser;
|
||||
this.music = new MusicManager();
|
||||
this.music.init(context, warpShip);
|
||||
}
|
||||
|
||||
private String getTxt(String key) {
|
||||
return bundle.getString(TosAmpDeskApp.class.getSimpleName()+"."+key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
music.stop();
|
||||
}
|
||||
|
||||
public void create() {
|
||||
getContours().setTitle(getTxt("title"));
|
||||
getContours().registrateContour(DeskAppContourSection.MAIN, this);
|
||||
getContours().registrateContour(DeskAppContourSection.FILE_NEW, new DeskAppRenderer() {
|
||||
@Override
|
||||
public void render() {
|
||||
if (ImGui.menuItem(getTxt("menuAdd"))) {
|
||||
fileChooser.chooseFile(fileChooserConfig,
|
||||
NativeFileChooserCallbackAdapter.onFileChosen(v -> music.addBackgroundMusic(v)));
|
||||
}
|
||||
}
|
||||
});
|
||||
fileChooserConfig = new NativeFileChooserConfiguration();
|
||||
fileChooserConfig.directory = Gdx.files.absolute(System.getProperty("user.home"));
|
||||
fileChooserConfig.mimeFilter = "audio/*";
|
||||
fileChooserConfig.title = "Choose audio file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
ImGui.text(getTxt("currentSong"));
|
||||
MusicSong currentSong = music.getCurrentSong();
|
||||
if (currentSong != null) {
|
||||
ImGui.sameLine();
|
||||
ImGui.text(currentSong.getName());
|
||||
}
|
||||
ImGui.separator();
|
||||
if (currentSong != null) {
|
||||
if (ImGui.button(getTxt("actionPlay"))) {
|
||||
music.play(currentSong);
|
||||
}
|
||||
} else {
|
||||
ImGui.text(getTxt("actionPlay"));
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("<")) {
|
||||
music.prev();
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(">")) {
|
||||
music.next();
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(getTxt("actionStop"))) {
|
||||
music.stop();
|
||||
}
|
||||
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
|
||||
ImGui.beginTable("playlist", 4, flags);
|
||||
ImGui.tableSetupColumn("#", ImGuiTableColumnFlags.NoHide);
|
||||
ImGui.tableSetupColumn(getTxt("listPlay"));
|
||||
ImGui.tableSetupColumn(getTxt("listName"));
|
||||
ImGui.tableSetupColumn(getTxt("listSong"));
|
||||
ImGui.tableHeadersRow();
|
||||
int i=1;
|
||||
for (MusicSong song:music.getMusicSongs()) {
|
||||
ImGui.pushID(i);
|
||||
ImGui.tableNextRow();
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.selectable(""+i, music.isPlaying(song), ImGuiSelectableFlags.None);
|
||||
ImGui.tableNextColumn();
|
||||
if (ImGui.smallButton(">")) {
|
||||
music.play(song);
|
||||
}
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.selectable(song.getPlaylist(), music.isPlaying(song), ImGuiSelectableFlags.None);
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.selectable(song.getName(), music.isPlaying(song), ImGuiSelectableFlags.None);
|
||||
ImGui.popID();
|
||||
i++;
|
||||
}
|
||||
ImGui.endTable();
|
||||
}
|
||||
|
||||
static class NativeFileChooserCallbackAdapter implements NativeFileChooserCallback {
|
||||
|
||||
@Override
|
||||
public void onFileChosen(FileHandle file) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancellation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception exception) {
|
||||
}
|
||||
|
||||
static NativeFileChooserCallbackAdapter onFileChosen(Consumer<FileHandle> eater) {
|
||||
return new NativeFileChooserCallbackAdapter() {
|
||||
@Override
|
||||
public void onFileChosen(FileHandle file) {
|
||||
eater.accept(file);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.gdxapp4d.app.tosamp.music;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
|
||||
|
||||
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public class M3UParser {
|
||||
|
||||
private static final String M3U_HEADER = "#EXTM3U";
|
||||
private static final String M3U_EXTINF = "#EXTINF:";
|
||||
private static final String M3U_PLAYLIST = "#PLAYLIST:";
|
||||
private static final String M3U_EXTALB = "#EXTALB:";
|
||||
private static final String M3U_EXTART = "#EXTART:";
|
||||
private static final String M3U_EXTGENRE = "#EXTGENRE:";
|
||||
private static final String M3U_EXTIMG = "#EXTIMG:";
|
||||
|
||||
public static class M3UPlaylist {
|
||||
private String name;
|
||||
private String albumTitle;
|
||||
private String albumArtist;
|
||||
private String albumGenre;
|
||||
private List<M3UTrack> tracks = new ArrayList<>();
|
||||
private Map<String, String> images = new HashMap<>();
|
||||
|
||||
public M3UPlaylist() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getAlbumTitle() {
|
||||
return albumTitle;
|
||||
}
|
||||
|
||||
public String getAlbumArtist() {
|
||||
return albumArtist;
|
||||
}
|
||||
|
||||
public String getAlbumGenre() {
|
||||
return albumGenre;
|
||||
}
|
||||
|
||||
public List<M3UTrack> getTracks() {
|
||||
return tracks;
|
||||
}
|
||||
|
||||
public Map<String, String> getImages() {
|
||||
return images;
|
||||
}
|
||||
}
|
||||
|
||||
public static class M3UTrack {
|
||||
private int time;
|
||||
private String name;
|
||||
private String file;
|
||||
|
||||
public M3UTrack() {
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
enum M3UExtLine {
|
||||
NONE,
|
||||
EXTINF,
|
||||
EXTIMG,
|
||||
}
|
||||
|
||||
public static M3UPlaylist parse(InputStream stream) throws IOException {
|
||||
M3UPlaylist result = new M3UPlaylist();
|
||||
M3UExtLine extLine = M3UExtLine.NONE;
|
||||
M3UTrack track = null;
|
||||
String imageType = null;
|
||||
|
||||
BufferedReader buffer = new BufferedReader(new InputStreamReader(stream));
|
||||
String line = buffer.readLine();
|
||||
if (!line.startsWith(M3U_HEADER)) {
|
||||
throw new IOException("Missing header");
|
||||
}
|
||||
|
||||
while ((line = buffer.readLine()) != null) {
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (extLine == M3UExtLine.EXTINF) {
|
||||
extLine = M3UExtLine.NONE;
|
||||
track.file = line;
|
||||
result.tracks.add(track);
|
||||
continue;
|
||||
}
|
||||
if (extLine == M3UExtLine.EXTIMG) {
|
||||
extLine = M3UExtLine.NONE;
|
||||
result.images.put(imageType, line);
|
||||
continue;
|
||||
}
|
||||
int arguIndex = line.indexOf(":");
|
||||
if (arguIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
String lineArgu = line.substring(arguIndex + 1);
|
||||
if (line.startsWith(M3U_PLAYLIST)) {
|
||||
result.name = lineArgu;
|
||||
} else if (line.startsWith(M3U_EXTALB)) {
|
||||
result.albumTitle = lineArgu;
|
||||
} else if (line.startsWith(M3U_EXTART)) {
|
||||
result.albumArtist = lineArgu;
|
||||
} else if (line.startsWith(M3U_EXTGENRE)) {
|
||||
result.albumGenre = lineArgu;
|
||||
} else if (line.startsWith(M3U_EXTIMG)) {
|
||||
imageType = lineArgu;
|
||||
extLine = M3UExtLine.EXTIMG;
|
||||
} else if (line.startsWith(M3U_EXTINF)) {
|
||||
track = new M3UTrack();
|
||||
extLine = M3UExtLine.EXTINF;
|
||||
int commaIndex = lineArgu.indexOf(",");
|
||||
String timeStr = lineArgu.substring(0, commaIndex);
|
||||
String trackName = lineArgu.substring(commaIndex + 1);
|
||||
track.time = Integer.parseInt(timeStr);
|
||||
track.name = trackName;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.gdxapp4d.app.tosamp.music;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.audio.Music.OnCompletionListener;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
import love.distributedrebirth.gdxapp4d.app.tosamp.music.M3UParser.M3UPlaylist;
|
||||
import love.distributedrebirth.gdxapp4d.app.tosamp.music.M3UParser.M3UTrack;
|
||||
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip;
|
||||
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
|
||||
|
||||
/**
|
||||
* Manages the background and others songs.
|
||||
*/
|
||||
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public class MusicManager {
|
||||
|
||||
private final List<MusicSong> musicSongs;
|
||||
private final NextSongListener nextSongListener;
|
||||
private MusicSong currentSong = null;
|
||||
private Music currentMusic = null;
|
||||
|
||||
public MusicManager() {
|
||||
musicSongs = new ArrayList<>();
|
||||
nextSongListener = new NextSongListener();
|
||||
}
|
||||
|
||||
public void addBackgroundMusic(FileHandle file) {
|
||||
musicSongs.add(new MusicSong(file, file.name(), ""));
|
||||
}
|
||||
|
||||
public void init(BundleContext context, SystemWarpShip warpShip) {
|
||||
List<File> playlists = warpShip.searchMagic(context, "audio/mpegurl");
|
||||
for (File playlist:playlists) {
|
||||
try {
|
||||
M3UPlaylist play = M3UParser.parse(new FileInputStream(playlist));
|
||||
|
||||
for (M3UTrack track:play.getTracks()) {
|
||||
FileHandle fileHandle = Gdx.files.absolute(playlist.getParent() + "/" + track.getFile());
|
||||
musicSongs.add(new MusicSong(fileHandle, track.getName(), play.getName()));
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (currentMusic != null) {
|
||||
currentMusic.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public List<MusicSong> getMusicSongs() {
|
||||
return musicSongs;
|
||||
}
|
||||
|
||||
public MusicSong getCurrentSong() {
|
||||
return currentSong;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (currentMusic != null) {
|
||||
currentMusic.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void play() {
|
||||
MusicSong nextSong = null;
|
||||
int currentBackground = musicSongs.indexOf(currentSong);
|
||||
if (currentBackground == -1 && !musicSongs.isEmpty()) {
|
||||
nextSong = musicSongs.get(0);
|
||||
} else {
|
||||
nextSong = currentSong;
|
||||
}
|
||||
if (nextSong!=null) {
|
||||
play(nextSong);
|
||||
}
|
||||
}
|
||||
|
||||
public void play(MusicSong song) {
|
||||
if (song == null) {
|
||||
return;
|
||||
}
|
||||
stop();
|
||||
currentSong = song;
|
||||
if (currentMusic != null) {
|
||||
currentMusic.dispose();
|
||||
}
|
||||
currentMusic = Gdx.audio.newMusic(currentSong.getFileHandle());
|
||||
currentMusic.setOnCompletionListener(nextSongListener);
|
||||
currentMusic.play();
|
||||
}
|
||||
|
||||
class NextSongListener implements OnCompletionListener {
|
||||
|
||||
@Override
|
||||
public void onCompletion(Music music) {
|
||||
next();
|
||||
play(currentSong);
|
||||
}
|
||||
}
|
||||
|
||||
public void next() {
|
||||
int currentBackground = musicSongs.indexOf(currentSong);
|
||||
if (currentBackground == -1) {
|
||||
return; // some other
|
||||
}
|
||||
if (currentBackground == musicSongs.size()-1) {
|
||||
currentBackground = -1; // loop to start
|
||||
}
|
||||
boolean play = currentMusic!=null && currentMusic.isPlaying();
|
||||
stop();
|
||||
currentSong = musicSongs.get(currentBackground+1);
|
||||
if (play) {
|
||||
play(currentSong);
|
||||
}
|
||||
}
|
||||
|
||||
public void prev() {
|
||||
int currentBackground = musicSongs.indexOf(currentSong);
|
||||
if (currentBackground == -1) {
|
||||
return; // some other
|
||||
}
|
||||
if (currentBackground == 0) {
|
||||
currentBackground = musicSongs.size(); // loop to end
|
||||
}
|
||||
boolean play = currentMusic!=null && currentMusic.isPlaying();
|
||||
stop();
|
||||
currentSong = musicSongs.get(currentBackground-1);
|
||||
if (play) {
|
||||
play(currentSong);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlaying(MusicSong song) {
|
||||
if (currentSong != null && currentSong.equals(song)) {
|
||||
return currentMusic.isPlaying();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.gdxapp4d.app.tosamp.music;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
|
||||
|
||||
/**
|
||||
* The music with the (file) name.
|
||||
*/
|
||||
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public class MusicSong {
|
||||
private final FileHandle fileHandle;
|
||||
private final String name;
|
||||
private final String playlist;
|
||||
|
||||
public MusicSong(FileHandle fileHandle, String name, String playlist) {
|
||||
this.fileHandle = fileHandle;
|
||||
this.name = name;
|
||||
this.playlist = playlist;
|
||||
}
|
||||
|
||||
public FileHandle getFileHandle() {
|
||||
return fileHandle;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getPlaylist() {
|
||||
return playlist;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
TosAmpDeskApp.title=\uf001 TosAmp
|
||||
TosAmpDeskApp.menuAdd=\uf067 Add
|
||||
TosAmpDeskApp.currentSong=Current Song:
|
||||
TosAmpDeskApp.actionPlay=Play
|
||||
TosAmpDeskApp.actionStop=Stop
|
||||
TosAmpDeskApp.listPlay=Do
|
||||
TosAmpDeskApp.listName=Playlist
|
||||
TosAmpDeskApp.listSong=Song
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
TosAmpDeskApp.title=\uf001 TosAmp
|
||||
TosAmpDeskApp.menuAdd=\uf067 \u6DFB\u52A0
|
||||
TosAmpDeskApp.currentSong=\u5F53\u524D\u6B4C\u66F2:
|
||||
TosAmpDeskApp.actionPlay=\u73A9
|
||||
TosAmpDeskApp.actionStop=\u505C\u6B62
|
||||
TosAmpDeskApp.listPlay=\u505A
|
||||
TosAmpDeskApp.listName=\u64AD\u653E\u5217\u8868
|
||||
TosAmpDeskApp.listSong=\u6B4C\u66F2
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
TosAmpDeskApp.title=\uf001 TosAmp
|
||||
TosAmpDeskApp.menuAdd=\uf067 Add
|
||||
TosAmpDeskApp.currentSong=Current Song:
|
||||
TosAmpDeskApp.actionPlay=Play
|
||||
TosAmpDeskApp.actionStop=Stop
|
||||
TosAmpDeskApp.listPlay=Do
|
||||
TosAmpDeskApp.listName=Playlist
|
||||
TosAmpDeskApp.listSong=Song
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
TosAmpDeskApp.title=\uf001 TosAmp
|
||||
TosAmpDeskApp.menuAdd=\uf067 Toevoegen
|
||||
TosAmpDeskApp.currentSong=Huidig lied:
|
||||
TosAmpDeskApp.actionPlay=Afspeel
|
||||
TosAmpDeskApp.actionStop=Stop
|
||||
TosAmpDeskApp.listPlay=Doe
|
||||
TosAmpDeskApp.listName=Speellijst
|
||||
TosAmpDeskApp.listSong=Lied
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
TosAmpDeskApp.title=\uf001 \u16CF\u16DF\u16CB\u16A8\u16D7\u16C8
|
||||
TosAmpDeskApp.menuAdd=\uf067 \u16A8\u16DE\u16DE
|
||||
TosAmpDeskApp.currentSong=\u16B2\u16A2\u16B1\u16B1\u16D6\u16BE\u16CF \u16CB\u16DF\u16BE\u16B7:
|
||||
TosAmpDeskApp.actionPlay=\u16C8\u16DA\u16A8\u16A4
|
||||
TosAmpDeskApp.actionStop=\u16CB\u16CF\u16DF\u16C8
|
||||
TosAmpDeskApp.listPlay=\u16DE\u16DF
|
||||
TosAmpDeskApp.listName=\u16C8\u16DA\u16A8\u16A4\u16DA\u16C1\u16CB\u16CF
|
||||
TosAmpDeskApp.listSong=\u16CB\u16DF\u16BE\u16B7
|
||||
Loading…
Add table
Add a link
Reference in a new issue