Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » javax.scene.media.Media does not understand protocol "bundleresource"(Can e(fx)clipse help?)
javax.scene.media.Media does not understand protocol "bundleresource" [message #1700485] Thu, 02 July 2015 21:26 Go to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi

I would like to play a sound file like this
Media buzzer = new Media(MainApplication.class.getClassLoader().getResource("sounds/buzzer.mp3").toExternalForm());
MediaPlayer mediaPlayer = new MediaPlayer(buzzer);
mediaPlayer.play();
and I was suprised to get this exception:
Exception in thread "JavaFX Application Thread" java.lang.UnsupportedOperationException: Unsupported protocol "bundleresource"
	at com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:233)
	at javafx.scene.media.Media.<init>(Media.java:391)

I was suprised that Media does not support the protocol "bundleresource" when Image does. Of couse I can figure out the location of file and use File.toURI().toString() to get the URI I can pass on to Media.

I am wondering why this pattern would work for an Image but not for a Media class? Does e(fx)clipse provide this protocol for Image (and could this be extended for Media) or is this built into JavaFX?

Cheers
Christoph
Re: javax.scene.media.Media does not understand protocol &quot;bundleresource&quot; [message #1700768 is a reply to message #1700485] Tue, 07 July 2015 05:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 02.07.15 23:26, Christoph Keimel wrote:
> Hi
>
> I would like to play a sound file like this
> Media buzzer = new
> Media(MainApplication.class.getClassLoader().getResource("sounds/buzzer.mp3").toExternalForm());
>
> MediaPlayer mediaPlayer = new MediaPlayer(buzzer);
> mediaPlayer.play();
> and I was suprised to get this exception:
> Exception in thread "JavaFX Application Thread"
> java.lang.UnsupportedOperationException: Unsupported protocol
> "bundleresource"
> at com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:233)
> at javafx.scene.media.Media.<init>(Media.java:391)
>
> I was suprised that Media does not support the protocol "bundleresource"
> when Image does. Of couse I can figure out the location of file and use
> File.toURI().toString() to get the URI I can pass on to Media.
>
> I am wondering why this pattern would work for an Image but not for a
> Media class? Does e(fx)clipse provide this protocol for Image (and could
> this be extended for Media) or is this built into JavaFX?
>

No we are not doing anything special for Image which most likely uses
Java-Streams whereas the media stuff directly delegates to the native
code to fetch the stream from an URL. Looking at the code the only 2
supported protocols are file: and http:

Tom
Re: javax.scene.media.Media does not understand protocol &quot;bundleresource&quot; [message #1700787 is a reply to message #1700768] Tue, 07 July 2015 08:45 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Thanks for the Info. I think it supports the jar: protocol too. I am using FileLocator.resolve(url) to convert the protocol which also works in an exported jar bundle.

Christoph
Re: javax.scene.media.Media does not understand protocol &amp;quot;bundleresource&amp;quot; [message #1716136 is a reply to message #1700787] Tue, 01 December 2015 15:51 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

There's no generic support for that:
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=483378
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=483390

See https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Media

Tom

On 07.07.15 10:45, Christoph Keimel wrote:
> Thanks for the Info. I think it supports the jar: protocol too. I am
> using FileLocator.resolve(url) to convert the protocol which also works
> in an exported jar bundle.
>
> Christoph
Re: javax.scene.media.Media does not understand protocol &amp;quot;bundleresource&amp;quot; [message #1716273 is a reply to message #1716136] Wed, 02 December 2015 15:56 Go to previous message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Very cool!
Previous Topic:Application model variables not declared as modifiable
Next Topic:org.eclipse.fx.javafx deprecation?
Goto Forum:
  


Current Time: Sat Apr 27 02:34:07 GMT 2024

Powered by FUDForum. Page generated in 0.03111 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top