Skip to content

Commit

Permalink
workaround: UrlAPI cannot load local file sources
Browse files Browse the repository at this point in the history
  • Loading branch information
SrRapero720 committed Nov 5, 2023
1 parent ee3e47e commit 38d802c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 38 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- UrlAPI: breaking change, result now returns a string instead of a URL
- WaterMedia API (deprecated): Removed url_toURL method
- Workaround (changes at the top): API cannot load pictures/videos from local sources
- Fixed: crash loading JPanel classes on linux

# UPDATE 2.0.9
- Fixed VLC is not loaded on ArchLinux using pacman (added /bin/ directory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class CallbackMediaPlayerComponent extends EmbeddedMediaPlayerComponentBa
/**
* Flag true if this component created the media player factory, or false if it was supplied by the caller.
*/
private boolean ownFactory;
private final boolean ownFactory;

/**
* Media player factory.
Expand Down Expand Up @@ -122,7 +122,7 @@ public CallbackMediaPlayerComponent(MediaPlayerFactory mediaPlayerFactory, FullS
if (renderCallback == null) {
this.defaultRenderCallback = new DefaultRenderCallback();
this.imagePainter = imagePainter == null ? new ScaledCallbackImagePainter() : imagePainter;
this.videoSurfaceComponent = new DefaultVideoSurfaceComponent();
this.videoSurfaceComponent = null;
bufferFormatCallback = new DefaultBufferFormatCallback();
renderCallback = this.defaultRenderCallback;
} else {
Expand Down Expand Up @@ -325,17 +325,7 @@ public final EmbeddedMediaPlayer mediaPlayer() {
return mediaPlayer;
}

/**
* Get the video surface {@link Canvas} component.
* <p>
* An application may want to add key/mouse listeners to the video surface component.
*
* @return video surface component
*/
public final JComponent videoSurfaceComponent() {
return videoSurfaceComponent;
}

// WATERMeDIA Patch - removed JComponent getter
/**
* Release the media player component and the associated native media player resources.
*/
Expand Down Expand Up @@ -365,31 +355,7 @@ public final MediaPlayerFactory mediaPlayerFactory() {
return mediaPlayerFactory;
}

/**
* Default implementation of a video surface component that uses a {@link CallbackImagePainter} to render the video
* image.
*/
private class DefaultVideoSurfaceComponent extends JPanel {

private DefaultVideoSurfaceComponent() {
setBackground(Color.black);
setIgnoreRepaint(true);
// Set a reasonable default size for the video surface component in case the client application does
// something like using pack() rather than setting a specific size
setPreferredSize(new Dimension(640, 360));
}

@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;

imagePainter.prepare(g2, this);
imagePainter.paint(g2, this, image);

onPaintOverlay(g2);
}
}

// WATERMeDIA Patch - Removed JPanel VideoSurface
/**
* Default implementation of a buffer format callback that returns a buffer format suitable for rendering into a
* {@link BufferedImage}.
Expand Down

0 comments on commit 38d802c

Please sign in to comment.