Skip to content

Commit

Permalink
Fix #548
Browse files Browse the repository at this point in the history
  • Loading branch information
berry120 committed Dec 25, 2023
1 parent cb2c012 commit 22cbd84
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 4 deletions.
1 change: 1 addition & 0 deletions Quelea/changelogs/changelog-2024.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ quelea (2024.0) stable
* Include all item types in printed order of service schedule
* Allow renaming of image group
* Prevent blacked stage view option
* Logo display now supports video files
* Critical fix: Using the French language no longer crashes Quelea when opening the options dialog
* Various minor bugfixes
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,7 @@ public void setLogoImage(String location) {
* @return the logo image
*/
public String getLogoImageURI() {
return "file:" + getProperty(logoImageLocationKey, "icons/logo default.png");
return new File(getProperty(logoImageLocationKey, "icons/logo default.png")).toURI().toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void handle(MouseEvent t) {
if (QueleaProperties.get().getLastDirectory() != null) {
chooser.setInitialDirectory(QueleaProperties.get().getLastDirectory());
}
chooser.getExtensionFilters().add(FileFilters.IMAGES);
chooser.getExtensionFilters().add(FileFilters.IMAGE_VIDEOS);
chooser.setInitialDirectory(QueleaProperties.get().getImageDir().getAbsoluteFile());
File file = chooser.showOpenDialog(QueleaApp.get().getMainWindow());
if (file != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import org.quelea.services.utils.ImageManager;
import org.quelea.services.utils.QueleaProperties;
import org.quelea.services.utils.Utils;
import org.quelea.windows.video.VidLogoDisplay;

import java.net.URI;

/**
* The logo image - on a separate stack pane with its background colour set so
Expand Down Expand Up @@ -58,10 +61,21 @@ public final void refresh() {
logoImage.setImage(Utils.getImageFromColour(QueleaProperties.get().getStageBackgroundColor()));
}
else {
logoImage.setImage(ImageManager.INSTANCE.getImage(QueleaProperties.get().getLogoImageURI()));
logoImage.setPreserveRatio(true);
String uri = QueleaProperties.get().getLogoImageURI();
if(isVid(uri)) {
VidLogoDisplay.INSTANCE.setURI(URI.create(uri));
logoImage.imageProperty().bind(VidLogoDisplay.INSTANCE.imageProperty());
}
else {
logoImage.setImage(ImageManager.INSTANCE.getImage(uri));
logoImage.setPreserveRatio(true);
}
}
logoImage.fitWidthProperty().bind(widthProperty());
logoImage.fitHeightProperty().bind(heightProperty());
}

private boolean isVid(String uri) {
return Utils.getVideoExtensions().stream().anyMatch(uri::endsWith);
}
}
66 changes: 66 additions & 0 deletions Quelea/src/main/java/org/quelea/windows/video/VidLogoDisplay.java
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();
}
}
}


}

0 comments on commit 22cbd84

Please sign in to comment.