diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..bd467c6 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,18 @@ +kind: pipeline +type: docker +name: default + +steps: + - name: test + image: maven:3-jdk-11 + commands: + - mvn -B -DskipTests clean package + - mvn test -B + volumes: + - name: m2 + path: /root/.m2 + +volumes: + - name: m2 + host: + path: /m2 \ No newline at end of file diff --git a/Readme.md b/Readme.md index 133724d..76ecd12 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # mplayer4anime -![License](https://img.shields.io/badge/License-GPLv3-blue.svg) ![Releases](https://img.shields.io/github/downloads/developersu/mplayer4anime/total.svg) ![CI](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fredrise.ru%2Fjen%2Fjob%2Fmplayer4anime%2Fjob%2Fmaster%2F) +![License](https://img.shields.io/badge/License-GPLv3-blue.svg) ![Releases](https://img.shields.io/github/downloads/developersu/mplayer4anime/total.svg) [![Build Status](https://ci.redrise.ru/api/badges/desu/mplayer4anime/status.svg)](https://ci.redrise.ru/desu/mplayer4anime) mplayer4anime is mplayer launcher to play video file with audio layer and/or subtitles (.ass, .srt, etc.) at once. diff --git a/src/main/java/mplayer4anime/mpv/MpvProcess.java b/src/main/java/mplayer4anime/mpv/MpvProcess.java index 9b2bda7..d857859 100644 --- a/src/main/java/mplayer4anime/mpv/MpvProcess.java +++ b/src/main/java/mplayer4anime/mpv/MpvProcess.java @@ -20,54 +20,21 @@ package mplayer4anime.mpv; import com.sun.jna.ptr.IntByReference; import mplayer4anime.ui.ServiceWindow; +import static mplayer4anime.mpv.Mpv_Events.*; +import static mplayer4anime.mpv.Mpv_Format.*; public class MpvProcess implements Runnable{ - private String videoFilename; + private final String videoFilename; + private final String audioFilename; + private final String subsFilename; + private final LibC libC = LibC.INSTANCE; private final LibMpv libMpv = LibMpv.INSTANCE; - /** MPV_FORMAT*/ - private final int MPV_FORMAT_NONE = 0; - private final int MPV_FORMAT_STRING = 1; - private final int MPV_FORMAT_OSD_STRING = 2; - private final int MPV_FORMAT_FLAG = 3; - private final int MPV_FORMAT_INT64 = 4; - private final int MPV_FORMAT_DOUBLE = 5; - private final int MPV_FORMAT_NODE = 6; - private final int MPV_FORMAT_NODE_ARRAY = 7; - private final int MPV_FORMAT_NODE_MAP = 8; - private final int MPV_FORMAT_BYTE_ARRAY = 9; - - /** mpv_event_id */ - private final int MPV_EVENT_NONE = 0; - private final int MPV_EVENT_SHUTDOWN = 1; - private final int MPV_EVENT_LOG_MESSAGE = 2; - private final int MPV_EVENT_GET_PROPERTY_REPLY = 3; - private final int MPV_EVENT_SET_PROPERTY_REPLY = 4; - private final int MPV_EVENT_COMMAND_REPLY = 5; - private final int MPV_EVENT_START_FILE = 6; - private final int MPV_EVENT_END_FILE = 7; - private final int MPV_EVENT_FILE_LOADED = 8; - private final int MPV_EVENT_TRACKS_CHANGED = 9;//DEPRECATED - private final int MPV_EVENT_TRACK_SWITCHED = 10;//DEPRECATED - private final int MPV_EVENT_IDLE = 11;//DEPRECATED - private final int MPV_EVENT_PAUSE = 12;//DEPRECATED - private final int MPV_EVENT_UNPAUSE = 13;//DEPRECATED - private final int MPV_EVENT_TICK = 14;//DEPRECATED - private final int MPV_EVENT_SCRIPT_INPUT_DISPATCH = 15;//DEPRECATED - private final int MPV_EVENT_CLIENT_MESSAGE = 16; - private final int MPV_EVENT_VIDEO_RECONFIG = 17; - private final int MPV_EVENT_AUDIO_RECONFIG = 18; - private final int MPV_EVENT_METADATA_UPDATE = 19;//DEPRECATED - private final int MPV_EVENT_SEEK = 20; - private final int MPV_EVENT_PLAYBACK_RESTART = 21; - private final int MPV_EVENT_PROPERTY_CHANGE = 22; - private final int MPV_EVENT_CHAPTER_CHANGE = 23;//DEPRECATED - private final int MPV_EVENT_QUEUE_OVERFLOW = 24; - private final int MPV_EVENT_HOOK = 25; - - MpvProcess(String filename){ - this.videoFilename = filename; + MpvProcess(String videoFilename, String audioFilename, String subsFilename){ + this.videoFilename = videoFilename; + this.audioFilename = audioFilename; + this.subsFilename = subsFilename; libC.setlocale(LibC.LC_NUMERIC, "C"); //Somehow it's important } @@ -81,14 +48,20 @@ public class MpvProcess implements Runnable{ libMpv.mpv_set_option_string(ctx, "input-default-bindings", "yes"); libMpv.mpv_set_option_string(ctx, "input-vo-keyboard", "yes"); IntByReference value = new IntByReference(1); - libMpv.mpv_set_option(ctx, "osc", MPV_FORMAT_FLAG, value); + libMpv.mpv_set_option(ctx, "osc", MPV_FORMAT_FLAG.ordinal(), value); libMpv.mpv_initialize(ctx); - libMpv.mpv_command(ctx, new String[]{"loadfile", videoFilename, null}); + + libMpv.mpv_command(ctx, new String[]{"loadfile", videoFilename}); + //libMpv.mpv_command(ctx, new String[]{"audio-add", audioFilename}); + //libMpv.mpv_command(ctx, new String[]{"subs-add", subsFilename}); while (true){ mpv_event event = libMpv.mpv_wait_event(ctx, 10000); - if (event.event_id == MPV_EVENT_SHUTDOWN) + if (event.event_id == MPV_EVENT_SHUTDOWN.ordinal()) break; - System.out.println(event.event_id); + System.out.println(Mpv_Events.values()[event.event_id].name()); + + if (event.event_id == MPV_EVENT_START_FILE.ordinal()) + libMpv.mpv_command(ctx, new String[]{"audio-add", audioFilename}); } libMpv.mpv_terminate_destroy(ctx); } diff --git a/src/main/java/mplayer4anime/mpv/MpvSlave.java b/src/main/java/mplayer4anime/mpv/MpvSlave.java index a514ee7..a6ae5ac 100644 --- a/src/main/java/mplayer4anime/mpv/MpvSlave.java +++ b/src/main/java/mplayer4anime/mpv/MpvSlave.java @@ -68,7 +68,7 @@ public class MpvSlave implements ISlaveModeAppOrchestration { boolean subtitlesHidden, boolean isFullscreen) { //TODO: fix - Thread thread = new Thread(new MpvProcess(VideoFile)); + Thread thread = new Thread(new MpvProcess(VideoFile, AudioFile, SubtitlesFile)); thread.start(); } diff --git a/src/main/java/mplayer4anime/mpv/Mpv_Events.java b/src/main/java/mplayer4anime/mpv/Mpv_Events.java new file mode 100644 index 0000000..d113a67 --- /dev/null +++ b/src/main/java/mplayer4anime/mpv/Mpv_Events.java @@ -0,0 +1,48 @@ +/* + Copyright 2018-2021 Dmitry Isaenko + + This file is part of mplayer4anime. + + mplayer4anime is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + mplayer4anime is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with mplayer4anime. If not, see . + */ +package mplayer4anime.mpv; + +public enum Mpv_Events { + MPV_EVENT_NONE,//0 + MPV_EVENT_SHUTDOWN,//1 + MPV_EVENT_LOG_MESSAGE,//2 + MPV_EVENT_GET_PROPERTY_REPLY,//3 + MPV_EVENT_SET_PROPERTY_REPLY,//4 + MPV_EVENT_COMMAND_REPLY,//5 + MPV_EVENT_START_FILE,//6 + MPV_EVENT_END_FILE,//7 + MPV_EVENT_FILE_LOADED,//8 + MPV_EVENT_TRACKS_CHANGED,//9 DEPRECATED + MPV_EVENT_TRACK_SWITCHED,//10 DEPRECATED + MPV_EVENT_IDLE,//11 DEPRECATED + MPV_EVENT_PAUSE,//12 DEPRECATED + MPV_EVENT_UNPAUSE,//13 DEPRECATED + MPV_EVENT_TICK,//14 DEPRECATED + MPV_EVENT_SCRIPT_INPUT_DISPATCH,//15 DEPRECATED + MPV_EVENT_CLIENT_MESSAGE,//16 + MPV_EVENT_VIDEO_RECONFIG,//17 + MPV_EVENT_AUDIO_RECONFIG,//18 + MPV_EVENT_METADATA_UPDATE,//19 DEPRECATED + MPV_EVENT_SEEK,//20 + MPV_EVENT_PLAYBACK_RESTART,//21 + MPV_EVENT_PROPERTY_CHANGE,//22 + MPV_EVENT_CHAPTER_CHANGE,//23 DEPRECATED + MPV_EVENT_QUEUE_OVERFLOW,//24 + MPV_EVENT_HOOK,//25 ; +} diff --git a/src/main/java/mplayer4anime/mpv/Mpv_Format.java b/src/main/java/mplayer4anime/mpv/Mpv_Format.java new file mode 100644 index 0000000..d08dab8 --- /dev/null +++ b/src/main/java/mplayer4anime/mpv/Mpv_Format.java @@ -0,0 +1,32 @@ +/* + Copyright 2018-2021 Dmitry Isaenko + + This file is part of mplayer4anime. + + mplayer4anime is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + mplayer4anime is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with mplayer4anime. If not, see . + */ +package mplayer4anime.mpv; + +public enum Mpv_Format { + MPV_FORMAT_NONE, //0; + MPV_FORMAT_STRING, //1; + MPV_FORMAT_OSD_STRING, //2; + MPV_FORMAT_FLAG, //3; + MPV_FORMAT_INT64, //4; + MPV_FORMAT_DOUBLE, //5; + MPV_FORMAT_NODE, //6; + MPV_FORMAT_NODE_ARRAY, //7; + MPV_FORMAT_NODE_MAP, //8; + MPV_FORMAT_BYTE_ARRAY; //9; +} diff --git a/src/main/java/mplayer4anime/playlists/Playlists.java b/src/main/java/mplayer4anime/playlists/Playlists.java index 3db69ab..2ee1698 100644 --- a/src/main/java/mplayer4anime/playlists/Playlists.java +++ b/src/main/java/mplayer4anime/playlists/Playlists.java @@ -90,8 +90,8 @@ public class Playlists { } /** * Interface for Opening playlists via FileChooser - * */ - public static JsonStorage Read(ResourceBundle resourceBundle){ + **/ + public static JsonStorage OpenPlaylistFileChooser(ResourceBundle resourceBundle){ File playlistFile; FileChooser fileChooser = new FileChooser(); diff --git a/src/main/java/mplayer4anime/ui/landing/LandingController.java b/src/main/java/mplayer4anime/ui/landing/LandingController.java index 271298b..0ff035e 100644 --- a/src/main/java/mplayer4anime/ui/landing/LandingController.java +++ b/src/main/java/mplayer4anime/ui/landing/LandingController.java @@ -108,6 +108,9 @@ public class LandingController implements Initializable { } playerToolbarController.initializeMainUiController(this); + /* + Playlists.ReadByPath(resourceBundle, playListFile); + * */ } public void setHostServices(HostServices hostServices) { @@ -167,7 +170,7 @@ public class LandingController implements Initializable { @FXML private void openBtn() { - JsonStorage jsonStorage = Playlists.Read(resourceBundle); + JsonStorage jsonStorage = Playlists.OpenPlaylistFileChooser(resourceBundle); setAllLists(jsonStorage); } private void setAllLists(JsonStorage jsonStorage){ diff --git a/src/main/java/mplayer4anime/ui/landing/panes/ControllerPane.java b/src/main/java/mplayer4anime/ui/landing/panes/ControllerPane.java index 9a0fb1e..0eeaa12 100644 --- a/src/main/java/mplayer4anime/ui/landing/panes/ControllerPane.java +++ b/src/main/java/mplayer4anime/ui/landing/panes/ControllerPane.java @@ -151,7 +151,7 @@ public class ControllerPane implements Initializable { lowerAndUpperExts.add(s); lowerAndUpperExts.add(s.toUpperCase()); } - String[] filesExtension = lowerAndUpperExts.toArray(new String[lowerAndUpperExts.size()]); + String[] filesExtension = lowerAndUpperExts.toArray(new String[0]); File directoryReceived; // Store files (folder) received from selector DirectoryChooser dirSelect;