JavaFX 19 - Media object bug
Kevin Rushforth
kevin.rushforth at oracle.com
Thu Sep 15 16:11:13 UTC 2022
This might be a regression introduced by the fix for
https://bugs.openjdk.org/browse/JDK-8282054
Can you file a bug at https://bugreport.java.com/ ?
Maybe Alexander can comment further.
-- Kevin
On 9/15/2022 8:27 AM, Alessandro Mercier wrote:
> Hello all,
>
> After this commit:
> https://github.com/openjdk/jfx/commit/d1110f479567c314ecb6848700bcf4552509d7e9
>
> Creating a new Media object using a MP3 file in the resources of a
> project, you can get exceptions:
>
> Exception in thread "JavaFX Application Thread" MediaException:
> MEDIA_UNSUPPORTED : Unrecognized file signature!
> at javafx.media at 20-ea/javafx.scene.media.Media.<init>(Media.java:411)
>
> At first glance, the error is in this Locator file in the JavaFX
> source code:
> https://github.com/openjdk/jfx/blob/master/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/Locator.java
>
> *Steps to reproduce the bug:*
> 1. Create a new Media object and load an MP3 from the resources
> 2. Watch the Media object throw a MediaException: MEDIA_UNSUPPORTED :
> Unrecognized file signature!
>
> *Example code that produces the bug:*
> final MediaPlayer mediaPlayer = new MediaPlayer(new
> Media(getClass().getResource("/path/to/file.mp3").toExternalForm()));
>
> *Extra:*
> I've made a free MP3 file available to try with here (royalty free):
> https://codedead.com/static.mp3
>
> I've also got a GIT repository in which the exception occurs
> immediately when running the Gradle task 'application':
> https://github.com/CodeDead/opal/tree/development (please make sure to
> use the development branch as this branch makes use of the latest
> JavaFX versions)
>
> Oddly enough, it does not always happen, and loading the file directly
> from a file location instead of the project resources seems to work,
> but when loading from the resources, you get the exception that the
> media file signature is not recognized.
> I don't see a problem with the media files themselves, encoding is all
> fine, at first glance and because it worked in JavaFX 18.0.2, creating
> a Media object using a URI to a project resources location should work
> in newer versions as well, I think. The same MP3 file does work when
> you load it from the disk instead of the project resources so this
> makes it a bug, I believe.
>
> The work-around right now is to revert back to JavaFX version 18.0.2.
>
> *System / OS / Runtime info:*
> Linux Fedora 36
> 5.19.8-200.fc36.x86_64
> openjdk version "18.0.2" 2022-07-19
> OpenJDK Runtime Environment (Red_Hat-18.0.2.0.9-1.rolling.fc36) (build
> 18.0.2+9)
> OpenJDK 64-Bit Server VM (Red_Hat-18.0.2.0.9-1.rolling.fc36) (build
> 18.0.2+9, mixed mode, sharing)
>
> Thank you and kind regards
>
> Alessandro Mercier
> --
> CodeDead Administrator
> https://codedead.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20220915/4a9d0703/attachment-0001.htm>
More information about the openjfx-dev
mailing list