Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge #11

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package io.github.pulsebeat02.ezmediacore.extraction;

import io.github.pulsebeat02.ezmediacore.LibraryInjectable;
import io.github.pulsebeat02.ezmediacore.playlist.youtube.Video;
import io.github.pulsebeat02.ezmediacore.playlist.youtube.VideoQuality;
import java.nio.file.Path;
import org.jetbrains.annotations.NotNull;

public interface VideoDownloader {
public interface VideoDownloader extends LibraryInjectable {

void downloadVideo(@NotNull final VideoQuality format, final boolean overwrite);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.pulsebeat02.ezmediacore.http;

import io.github.pulsebeat02.ezmediacore.LibraryInjectable;
import java.net.Socket;
import java.nio.file.Path;
import org.jetbrains.annotations.NotNull;

public interface HttpDaemon {
public interface HttpDaemon extends LibraryInjectable {

void start();

Expand All @@ -30,6 +31,6 @@ public interface HttpDaemon {

@NotNull
default Path getRelativePath(@NotNull final Path file) {
return getServerPath().relativize(file);
return this.getServerPath().relativize(file);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.github.pulsebeat02.ezmediacore.persistent;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import org.jetbrains.annotations.NotNull;

public interface SerializableComponent<T> {

void serialize(@NotNull final List<T> list) throws IOException;

List<T> deserialize() throws IOException;

@NotNull
Path getStorageFile();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.github.pulsebeat02.ezmediacore.resourcepack.hosting;

import io.github.pulsebeat02.ezmediacore.LibraryInjectable;
import io.github.pulsebeat02.ezmediacore.http.HttpDaemon;
import org.jetbrains.annotations.NotNull;

public interface HttpDaemonSolution extends HostingSolution {
public interface HttpDaemonSolution extends LibraryInjectable, HostingSolution {

void startServer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public ImmutableDimension(final int width, final int height) {
this.height = height;
}

public static ImmutableDimension deserialize(@NotNull final Map<String, Object> args) {
return new ImmutableDimension((int) args.get("width"), (int) args.get("height"));
}

public int getWidth() {
return this.width;
}
Expand All @@ -30,7 +26,7 @@ public int getHeight() {
@Override
public @NotNull Map<String, Object> serialize() {
return ImmutableMap.of(
"width", width,
"height", height);
"width", this.width,
"height", this.height);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import io.github.pulsebeat02.deluxemediaplugin.utility.ChatUtils;
import io.github.pulsebeat02.ezmediacore.ffmpeg.FFmpegAudioTrimmer;
import io.github.pulsebeat02.ezmediacore.player.PlayerControls;
import io.github.pulsebeat02.ezmediacore.player.VideoPlayer;
import io.github.pulsebeat02.ezmediacore.utility.PathUtils;
import io.github.pulsebeat02.ezmediacore.utility.ResourcepackUtils;
import io.github.pulsebeat02.minecraftmedialibrary.ffmpeg.FFmpegAudioTrimmerHelper;
import io.github.pulsebeat02.minecraftmedialibrary.frame.player.VideoPlayerContext;
import io.github.pulsebeat02.minecraftmedialibrary.resourcepack.PackWrapper;
import io.github.pulsebeat02.minecraftmedialibrary.resourcepack.ResourcepackWrapper;
import io.github.pulsebeat02.minecraftmedialibrary.utility.PathUtilities;
import io.github.pulsebeat02.minecraftmedialibrary.utility.VideoExtractionUtilities;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -167,7 +167,7 @@ private int resumeVideo(@NotNull final CommandContext<CommandSender> context) {
private void buildResourcepack() {
final Path audio = this.attributes.getAudio();
final Path ogg = audio.getParent().resolve("temp.ogg");
new FFmpegAudioTrimmer(this.plugin().library(), audio, ogg, this.attributes.getPlayer())
new FFmpegAudioTrimmer(this.plugin().library(), audio, ogg, this.attributes.getPlayer());
}

public void sendResourcepackFile() {
Expand All @@ -192,27 +192,21 @@ private boolean mediaProcessingIncomplete(@NotNull final Audience audience) {
}

private void stopIfPlaying() {
final VideoPlayerContext player = this.attributes.getPlayer();
if (player != null && player.isPlaying()) {
player.stop(Bukkit.getOnlinePlayers());
final VideoPlayer player = this.attributes.getPlayer();
if (player != null) {
if (player.getPlayerState() == PlayerControls.START || player.getPlayerState() == PlayerControls.RESUME) {
player.setPlayerState(PlayerControls.PAUSE);
}
}
}

private void sendPlayInformation(@NotNull final Audience audience) {
if (this.attributes.isYoutube()) {
audience.sendMessage(
format(
text(
String.format("Starting Video on URL: %s", this.attributes.getExtractor().getUrl()),
GOLD)));
gold(audience, String.format("Starting Video on URL: %s", this.attributes.getExtractor().getUrl()));
} else {
audience.sendMessage(
format(
text(
String.format(
"Starting Video on File: %s",
PathUtilities.getName(Paths.get(this.attributes.getVideo()))),
GOLD)));
gold(audience, String.format(
"Starting Video on File: %s",
PathUtils.getName(Paths.get(this.attributes.getVideo()))));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public final class VideoCommandAttributes {

private final AtomicBoolean completion;

private YoutubeExtraction extractor;
private VideoPlayer player;
private DitherSetting dither;
private VideoType mode;
Expand All @@ -50,133 +49,125 @@ public final class VideoCommandAttributes {
private byte[] hash;

public VideoCommandAttributes() {
dither = DitherSetting.FILTER_LITE;
frameWidth = 5;
frameHeight = 5;
screenWidth = 640;
screenHeight = 360;
completion = new AtomicBoolean(false);
mode = VideoType.ITEMFRAME;
this.dither = DitherSetting.FILTER_LITE;
this.frameWidth = 5;
this.frameHeight = 5;
this.screenWidth = 640;
this.screenHeight = 360;
this.completion = new AtomicBoolean(false);
this.mode = VideoType.ITEMFRAME;
}

public DitherSetting getDither() {
return dither;
return this.dither;
}

public void setDither(final DitherSetting dither) {
this.dither = dither;
}

public YoutubeExtraction getExtractor() {
return extractor;
}

public void setExtractor(final YoutubeExtraction extractor) {
this.extractor = extractor;
}

public VideoPlayer getPlayer() {
return player;
return this.player;
}

public void setPlayer(final VideoPlayer player) {
this.player = player;
}

public String getVideo() {
return video;
return this.video;
}

public void setVideoMrl(final String video) {
this.video = video;
}

public boolean isYoutube() {
return youtube;
return this.youtube;
}

public void setYoutube(final boolean youtube) {
this.youtube = youtube;
}

public int getFrameWidth() {
return frameWidth;
return this.frameWidth;
}

public void setFrameWidth(final int frameWidth) {
this.frameWidth = frameWidth;
}

public int getFrameHeight() {
return frameHeight;
return this.frameHeight;
}

public void setFrameHeight(final int frameHeight) {
this.frameHeight = frameHeight;
}

public int getScreenWidth() {
return screenWidth;
return this.screenWidth;
}

public void setScreenWidth(final int screenWidth) {
this.screenWidth = screenWidth;
}

public int getScreenHeight() {
return screenHeight;
return this.screenHeight;
}

public void setScreenHeight(final int screenHeight) {
this.screenHeight = screenHeight;
}

public int getStartingMap() {
return startingMap;
return this.startingMap;
}

public void setStartingMap(final int startingMap) {
this.startingMap = startingMap;
}

public AtomicBoolean getCompletion() {
return completion;
return this.completion;
}

public VideoType getVideoType() {
return mode;
return this.mode;
}

public void setVideoType(@NotNull final VideoType type) {
mode = type;
this.mode = type;
}

public VideoType getMode() {
return mode;
return this.mode;
}

public void setMode(final VideoType mode) {
this.mode = mode;
}

public String getResourcepackUrl() {
return resourcepackUrl;
return this.resourcepackUrl;
}

public void setResourcepackUrl(final String resourcepackUrl) {
this.resourcepackUrl = resourcepackUrl;
}

public byte[] getHash() {
return hash;
return this.hash;
}

public void setHash(final byte[] hash) {
this.hash = hash;
}

public Path getAudio() {
return audio;
return this.audio;
}

public void setAudio(final Path audio) {
Expand Down
Loading