Can playback video with controls, need to fix performance and reducing window size
This commit is contained in:
@@ -1,20 +1,90 @@
|
||||
package com.github.gtache.autosubtitle;
|
||||
|
||||
import com.github.gtache.autosubtitle.subtitle.Subtitle;
|
||||
import com.github.gtache.autosubtitle.subtitle.SubtitleCollection;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Translates texts and subtitles
|
||||
*/
|
||||
public interface Translator {
|
||||
|
||||
/**
|
||||
* Guesses the locale of the given text
|
||||
*
|
||||
* @param text The text
|
||||
* @return The guessed locale
|
||||
*/
|
||||
Locale getLocale(final String text);
|
||||
|
||||
/**
|
||||
* Guesses the locale of the given subtitle
|
||||
*
|
||||
* @param subtitle The subtitle
|
||||
* @return The guessed locale
|
||||
*/
|
||||
default Locale getLocale(final Subtitle subtitle) {
|
||||
return getLocale(subtitle.content());
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the given text to the given locale
|
||||
*
|
||||
* @param text The text to translate
|
||||
* @param to The target locale
|
||||
* @return The translated text
|
||||
*/
|
||||
String translate(String text, Locale to);
|
||||
|
||||
/**
|
||||
* Translates the given text to the given locale
|
||||
*
|
||||
* @param text The text to translate
|
||||
* @param to The target locale
|
||||
* @return The translated text
|
||||
*/
|
||||
default String translate(final String text, final String to) {
|
||||
return translate(text, Locale.forLanguageTag(to));
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the given subtitle to the given locale
|
||||
*
|
||||
* @param subtitle The subtitle to translate
|
||||
* @param to The target locale
|
||||
* @return The translated subtitle
|
||||
*/
|
||||
Subtitle translate(Subtitle subtitle, Locale to);
|
||||
|
||||
/**
|
||||
* Translates the given subtitle to the given locale
|
||||
*
|
||||
* @param subtitle The subtitle to translate
|
||||
* @param to The target locale
|
||||
* @return The translated subtitle
|
||||
*/
|
||||
default Subtitle translate(final Subtitle subtitle, final String to) {
|
||||
return translate(subtitle, Locale.forLanguageTag(to));
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the given subtitles collection to the given locale
|
||||
*
|
||||
* @param collection The subtitles collection to translate
|
||||
* @param to The target locale
|
||||
* @return The translated subtitles collection
|
||||
*/
|
||||
default SubtitleCollection translate(final SubtitleCollection collection, final String to) {
|
||||
return translate(collection, Locale.forLanguageTag(to));
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the given subtitles collection to the given locale
|
||||
*
|
||||
* @param collection The subtitles collection to translate
|
||||
* @param to The target locale
|
||||
* @return The translated subtitles collection
|
||||
*/
|
||||
SubtitleCollection translate(SubtitleCollection collection, Locale to);
|
||||
}
|
||||
|
||||
@@ -18,4 +18,5 @@ public interface Video {
|
||||
* @return The video info
|
||||
*/
|
||||
VideoInfo info();
|
||||
|
||||
}
|
||||
|
||||
@@ -8,4 +8,27 @@ public interface VideoInfo {
|
||||
* @return The video extension (mp4, etc.)
|
||||
*/
|
||||
String videoFormat();
|
||||
|
||||
/**
|
||||
* @return The video width in pixels
|
||||
*/
|
||||
int width();
|
||||
|
||||
/**
|
||||
* @return The video height in pixels
|
||||
*/
|
||||
int height();
|
||||
|
||||
|
||||
/**
|
||||
* @return The video duration in milliseconds
|
||||
*/
|
||||
long duration();
|
||||
|
||||
/**
|
||||
* @return The aspect ratio of the video
|
||||
*/
|
||||
default double aspectRatio() {
|
||||
return (double) width() / height();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.github.gtache.autosubtitle;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Loads videos
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface VideoLoader {
|
||||
|
||||
/**
|
||||
* Loads a video
|
||||
*
|
||||
* @param path The path to the video
|
||||
* @return The loaded video
|
||||
* @throws IOException If an error occurred
|
||||
*/
|
||||
Video loadVideo(final Path path) throws IOException;
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.github.gtache.autosubtitle.setup;
|
||||
|
||||
/**
|
||||
* Exception thrown when an error occurs during setup
|
||||
*/
|
||||
public class SetupException extends Exception {
|
||||
|
||||
public SetupException(final String message) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public interface SetupManager {
|
||||
* @throws SetupException if an error occurred during the check
|
||||
*/
|
||||
default boolean isInstalled() throws SetupException {
|
||||
return status() != SetupStatus.NOT_INSTALLED;
|
||||
return status().isInstalled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,5 +4,9 @@ package com.github.gtache.autosubtitle.setup;
|
||||
* The status of a setup
|
||||
*/
|
||||
public enum SetupStatus {
|
||||
NOT_INSTALLED, INSTALLED, UPDATE_AVAILABLE
|
||||
ERRORED, NOT_INSTALLED, INSTALLED, UPDATE_AVAILABLE;
|
||||
|
||||
public boolean isInstalled() {
|
||||
return this == INSTALLED || this == UPDATE_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.github.gtache.autosubtitle.subtitle;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Represents a collection of {@link Subtitle}
|
||||
@@ -13,7 +14,7 @@ public interface SubtitleCollection {
|
||||
Collection<? extends Subtitle> subtitles();
|
||||
|
||||
/**
|
||||
* @return The language of the subtitles
|
||||
* @return The locale of the subtitles
|
||||
*/
|
||||
String language();
|
||||
Locale locale();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Collection;
|
||||
*/
|
||||
public interface SubtitleExtractor {
|
||||
|
||||
Collection<EditableSubtitle> extract(final Video in);
|
||||
Collection<? extends EditableSubtitle> extract(final Video in);
|
||||
|
||||
Collection<EditableSubtitle> extract(final Audio in);
|
||||
Collection<? extends EditableSubtitle> extract(final Audio in);
|
||||
}
|
||||
|
||||
9
api/src/main/java/module-info.java
Normal file
9
api/src/main/java/module-info.java
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* API module for auto-subtitle
|
||||
*/
|
||||
module com.github.gtache.autosubtitle.api {
|
||||
exports com.github.gtache.autosubtitle;
|
||||
exports com.github.gtache.autosubtitle.process;
|
||||
exports com.github.gtache.autosubtitle.setup;
|
||||
exports com.github.gtache.autosubtitle.subtitle;
|
||||
}
|
||||
Reference in New Issue
Block a user