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

JavaFX Video Player #326

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5a5d752
Beginnings of video player
Gamebuster19901 Mar 28, 2020
040423d
Video manager is no longer a singleton.
Gamebuster19901 Mar 28, 2020
fb5db72
Make VideoManager a GuiComponent
Gamebuster19901 Mar 28, 2020
f625f86
Make javafx verify code stop running when the library has loaded
Gamebuster19901 Mar 28, 2020
e31e840
Don't reduce visibility of getPanel()
Gamebuster19901 Mar 28, 2020
7ea07dd
Don't import from javafx
Gamebuster19901 Mar 28, 2020
be6cebd
Make VideoManagers a resource
Gamebuster19901 Mar 28, 2020
915ae4f
Fix deadlock
Gamebuster19901 Mar 29, 2020
afbd82b
Fix more threading issues
Gamebuster19901 Mar 29, 2020
b81b2ef
Don't need to store mediaPlayer
Gamebuster19901 Mar 29, 2020
fb48a25
Fix black screen
Gamebuster19901 Mar 29, 2020
ec99a8a
Add JavaFX to classpath (#3)
Gamebuster19901 Mar 29, 2020
93ff4f8
Merge branch 'master' into video
Gamebuster19901 Mar 29, 2020
89ccf68
Merge branch 'master' of https://github.com/gurkenlabs/litiengine int…
Gamebuster19901 Mar 31, 2020
2ea2793
This property should never be set.
Gamebuster19901 Mar 31, 2020
3f64360
Add javadocs
Gamebuster19901 Mar 31, 2020
cad48ab
I Forgot to push VideoRenderer previously
Gamebuster19901 Mar 31, 2020
22d0b0e
Fix javadoc and improve security of url (#4)
Gamebuster19901 Mar 31, 2020
02ed3ca
Fixed threading issues that occured as a result of the previous changes
Gamebuster19901 Mar 31, 2020
4ba1d37
Implement VideoRenderer, Closes gurkenlabs#291
Gamebuster19901 Mar 31, 2020
02ed166
Video resource manager (no implementation provided)
Gamebuster19901 Apr 25, 2020
da48c6d
Merge branch 'master' of https://github.com/gurkenlabs/litiengine int…
Gamebuster19901 Apr 25, 2020
a2c09cd
Make VideoManager abstract
Gamebuster19901 Apr 25, 2020
fa110a0
Added video manager factory
Gamebuster19901 Apr 25, 2020
7dfeb35
Merge branch 'videoResource' into video
Gamebuster19901 Apr 25, 2020
0343693
VideoManagerImpl -> JavaFXVideoManager
Gamebuster19901 Apr 25, 2020
dbbf2e4
change visibility
Gamebuster19901 Apr 25, 2020
355e78e
Remove unecessary method overrides
Gamebuster19901 Apr 25, 2020
d097228
Merge branch 'videoResource' into 'video'
Gamebuster19901 Apr 25, 2020
7138a8f
Fix NoSuchMethodException
Gamebuster19901 Apr 25, 2020
d1dac5a
Fix NullPointerException
Gamebuster19901 Apr 25, 2020
0d23c0d
Fix missing toolkit caused by the new changes
Gamebuster19901 Apr 25, 2020
9a371b1
Fix javadoc
Gamebuster19901 Apr 25, 2020
3cde0fb
Merge branch 'videoResource' into 'video'
Gamebuster19901 Apr 25, 2020
2716c97
Fix missing toolkit for url videos
Gamebuster19901 Apr 25, 2020
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
50 changes: 25 additions & 25 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="tests">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="tests">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
4 changes: 2 additions & 2 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ install: true
before_install:
- chmod +x gradlew
- sudo apt-get -y install at-spi2-core

jdk: openjdk11
- sudo apt-get -y install openjfx
jdk:
- openjdk11
- openjdk8

git:
depth: false
Expand Down
19 changes: 19 additions & 0 deletions build-maven.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
buildscript {
dependencies {
if(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
classpath "org.openjfx:javafx-plugin:0.0.8"
}
}
}

apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

if(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
apply plugin: 'org.openjfx.javafxplugin'
javafx {
version = "11.0.2"
modules = ['javafx.media', 'javafx.swing']
}
}

sourceSets {
main.java.srcDir "src"
main.resources.srcDir "resources"
Expand Down Expand Up @@ -36,6 +52,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.1'
testImplementation 'org.mockito:mockito-core:2.25.1'

}

test {
Expand Down Expand Up @@ -93,6 +110,8 @@ tasks.withType(JavaCompile) {
group = "de.gurkenlabs"
archivesBaseName = "litiengine"
version = "0.4.20"
sourceCompatibility = "8"
targetCompatibility = "8"

publishing {
publications {
Expand Down
17 changes: 16 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@ buildscript {
repositories {
mavenCentral()
}
dependencies {
if(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
classpath "org.openjfx:javafx-plugin:0.0.8"
}
}
}

plugins {
plugins {
id 'com.stehno.natives' version '0.3.1'
id 'org.sonarqube' version '2.8'
}

if(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
apply plugin: 'org.openjfx.javafxplugin'
javafx {
version = "11.0.2"
modules = ['javafx.media', 'javafx.swing']
}
}

natives {
configurations = ['runtimeClasspath']
outputDir = 'libs'
Expand All @@ -19,6 +32,8 @@ apply plugin: 'jacoco'

archivesBaseName = "litiengine"
version = "v0.4.20-alpha"
sourceCompatibility = "8"
targetCompatibility = "8"

sourceSets {
main.java.srcDir "src"
Expand Down
22 changes: 22 additions & 0 deletions src/de/gurkenlabs/litiengine/graphics/VideoRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package de.gurkenlabs.litiengine.graphics;

import java.awt.Graphics2D;

import de.gurkenlabs.litiengine.video.VideoManager;

public final class VideoRenderer {

private VideoRenderer() {
throw new UnsupportedOperationException();
}

public static void render(final Graphics2D g, final VideoManager video) {
if(video == null || video.isStatusUnknown()) {
return;
}
g.translate(video.getX(), video.getY());
video.getPanel().paint(g);
g.translate(-video.getX(), -video.getY());
}

}
14 changes: 14 additions & 0 deletions src/de/gurkenlabs/litiengine/resources/Resources.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* <li>(localizable) strings</li>
* <li>spritesheets</li>
* <li>sounds</li>
* <li>videos</li>
* </ul>
*
* @see ResourcesContainer
Expand All @@ -55,6 +56,7 @@ public final class Resources {
private static Images images = new Images();
private static Spritesheets spritesheets = new Spritesheets();
private static Blueprints blueprints = new Blueprints();
private static Videos videos = new Videos();

private Resources() {
throw new UnsupportedOperationException();
Expand Down Expand Up @@ -148,6 +150,17 @@ public static Spritesheets spritesheets() {
public static Blueprints blueprints() {
return blueprints;
}

/**
* Gets the container that manages <code>VideoManager</code> resources.
*
* @return The VideoManager resource container.
*
* @see de.gurkenlabs.litiengine.video.VideoManager
*/
public static Videos videos() {
return videos;
}

/**
* Load <code>Spritesheets</code>, <code>Tilesets</code> and <code>Maps</code> from a game resource file created with the utiLITI editor.
Expand Down Expand Up @@ -332,6 +345,7 @@ public static void clearAll() {
tilesets().clear();
images().clear();
spritesheets().clear();
videos().clear();
}

public static URL getLocation(String name) {
Expand Down
38 changes: 38 additions & 0 deletions src/de/gurkenlabs/litiengine/resources/VideoResource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.gurkenlabs.litiengine.resources;

import java.net.URI;

import de.gurkenlabs.litiengine.video.VideoManagerFactory;

public class VideoResource extends NamedResource {

private final String player;
private final String uri;

public VideoResource(String uri, String name) {
this(VideoManagerFactory.getDefaultPlayer(), uri, name);
}

public VideoResource(URI uri, String name) {
this(VideoManagerFactory.getDefaultPlayer(), uri, name);
}

public VideoResource(String player, String uri, String name) {
this.player = player;
this.uri = uri;
setName(name);
}

public VideoResource(String player, URI uri, String name) {
this(player, uri.toString(), name);
}

public String getURI() {
return uri;
}

public String getPlayerType() {
return player;
}

}
30 changes: 30 additions & 0 deletions src/de/gurkenlabs/litiengine/resources/Videos.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package de.gurkenlabs.litiengine.resources;

import java.net.URL;

import de.gurkenlabs.litiengine.video.VideoManager;
import de.gurkenlabs.litiengine.video.VideoManagerFactory;

public class Videos extends ResourcesContainer<VideoManager>{

Videos(){}

public VideoManager load(VideoResource video) throws NoClassDefFoundError {
return load(video, false);
}

public VideoManager load(VideoResource video, boolean play) throws NoClassDefFoundError {
VideoManager videoManager = VideoManagerFactory.create(video);
if(play) {
videoManager.play();
}
this.add(video.getName(), videoManager);
return videoManager;
}

@Override
protected VideoManager load(URL resourceName) throws Exception, NoClassDefFoundError {
return VideoManagerFactory.create(new VideoResource(resourceName.toURI(), resourceName.toString()));
}

}
Loading