-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Quelea/src/main/java/org/quelea/windows/video/VidLogoDisplay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.quelea.windows.video; | ||
|
||
import javafx.beans.property.ReadOnlyObjectProperty; | ||
import javafx.beans.property.ReadOnlyObjectWrapper; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.image.WritableImage; | ||
import javafx.scene.paint.Color; | ||
import org.freedesktop.gstreamer.Bus; | ||
import org.freedesktop.gstreamer.Format; | ||
import org.freedesktop.gstreamer.elements.PlayBin; | ||
import org.freedesktop.gstreamer.event.SeekFlags; | ||
import org.quelea.services.utils.GStreamerInitState; | ||
|
||
import java.net.URI; | ||
import java.util.EnumSet; | ||
import java.util.Objects; | ||
|
||
public class VidLogoDisplay { | ||
|
||
public static final VidLogoDisplay INSTANCE = new VidLogoDisplay(); | ||
|
||
|
||
private PlayBin playBin; | ||
private FXImageSink fxImageSink; | ||
private URI uri; | ||
private static final Image BLANK_IMG; | ||
|
||
static { | ||
BLANK_IMG = new WritableImage(1, 1); | ||
((WritableImage) BLANK_IMG).getPixelWriter().setColor(0, 0, Color.BLACK); | ||
} | ||
|
||
private VidLogoDisplay() { | ||
if (GStreamerInitState.INIT_SUCCESS) { | ||
fxImageSink = new FXImageSink(); | ||
playBin = new PlayBin("playbin logo"); | ||
playBin.setVideoSink(fxImageSink.getSinkElement()); | ||
playBin.getBus().connect((Bus.EOS) source -> { | ||
playBin.seekSimple(Format.TIME, EnumSet.of(SeekFlags.FLUSH), 0); | ||
}); | ||
playBin.setVolume(0); | ||
} | ||
} | ||
|
||
public ReadOnlyObjectProperty<Image> imageProperty() { | ||
if (fxImageSink == null) { | ||
return new ReadOnlyObjectWrapper<>(BLANK_IMG); | ||
} | ||
return fxImageSink.imageProperty(); | ||
} | ||
|
||
|
||
public void setURI(URI uri) { | ||
if (!Objects.equals(this.uri, uri)) { | ||
this.uri = uri; | ||
if (playBin != null) { | ||
playBin.stop(); | ||
fxImageSink.clear(); | ||
playBin.setURI(uri); | ||
playBin.play(); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |