Detect if JavaFX Media required codecs are installed - java

According to the following:
http://www.oracle.com/technetwork/java/javase/certconfig-2095354.html
In order for JavaFX media to work, the given OS needs proper codecs installed.
In my application, I am trying to play an mp4 video. If the given platform is not able to play it, I display a static image instead.
In such a case, if it is unable to play it, I was expecting it to throw an exception and I would handle it accordingly.
However, it does not do so and instead displays a blank area where the video should be.
How can one detect if the required codec is installed or not?
I was testing this on Windows Server 2008 where I got this symptom. Windows 7, 8, and 10 work as expected.

You don't need to check if the OS has the codec because Java includes most of them (Mpeg-4/mp4 is included), the problem is that window's server edition isn't able to play videos.

Related

Playing h265 HEVC in a JavaFX client

I had a small JavaFX application to play some GoPro videos on a windows / linux client. In the past I had using a GoPro 4. I've downloaded the video to the client and play it from the local storage. Like this:
File file = new File("AnyVideo.MP4");
Media m = new Media(file.toURI().toString());
MediaPlayer mp = new MediaPlayer(m);
mp.setAutoPlay(true);
mediaView.setMediaPlayer(mp);
I'll try to switch to the new GoPro 6 now. But it doesn't worked as expected.
The problem is probably that the JavaFX MediaPlayer did not support the codec from the new GoPro 6.
GoPro 4: h264 AVC video codec
GoPro 6: h265 HEVC video codec
The JavaFX MediaPlayer supports only the h264 codec.
Did anyone know a way how I can play a h265 HEVC video with my JavaFX application. In the best case a solution wich can play the video immediatly from the camera without download the video first to the client. The GoPro has a smal Media Server to get the video over HTTP. as example:
http://10.5.5.9:8080/videos/DCIM/100/GPR10973.MP4
Native JavaFX Solution
Perhaps this is a duplicate or at least related to:
Adding other video codecs / DVD support to JavaFX 2.2.
See my answer to that question for links to related feature requests in the JavaFX bug tracker system.
Solutions using non-JavaFX tech from JavaFX
There are other solutions than those discussed in answers to that question which may work for you. Especially if your primary concern is just getting some kind of playback, even if it doesn't have deep integration with the JavaFX media system.
For instance, other approaches than native JavaFX playback could be:
Using VLCJ with some kind of Swing integration (such as a SwingNode, though that may or may not work).
Rendering the VLCJ video into a JavaFX ImageView or Canvas.
See related: Playing Video in Java FX using vlcj api.
Which links to the following project: https://github.com/caprica/vlcj-javafx.
Launch a native video player if you don't need the video embedded.
Perhaps Desktop.open() or the Process API could do this.
Call ffmpeg to convert h265 to h264.
I don't know much about this, but a quick google of the topic shows up references to the xuggle project.
Current status of the xuggler project is:
Xuggler is on hiatus as no one is actively developing it anymore. Sorry. That said, you can always find the source code and start hacking yourself. Good luck!
So I wish you good luck with that ;-)
Launching the native browser through a HostServices.showDocument() call to display the video.
Use a third party browsing component that can be integrated into JavaFX and includes support for the media type you want to play back, for example JxBrowser:
H.265 support in jxbrowser
Of the options outlined above, personally, I would recommend using HostServices to play the video in the native browser if that kind of solution will possibly work for you.
Going into detail on various options is probably out of scope for StackOverflow (even the above list starts looking like a sometimes frowned upon library recommendation).

Facing Issue While Playing a Video in Linux using VLCJ and JMF

I want to play a video in frame using Java code in LUbuntu.
Till now I have used JMF and VLCJ framework for playing a video, it works absolutely fine on windows but not on Linux (It gives me FATAL error if I use VLCJ even for the same code which runs on windows and JMF doesn't get install on linux-ubuntu).
I have used 32 bit Linux and 1.8 JDK. Is there compatibility issue with Linux drivers and JMF drivers ?
But now I am trying to run via any script that will enable me playing a video on a frame not on browser.
It will be great if you give me proper guidance.
Thank you.
vlcj currently will not work on 32-bit Ubuntu, at least not without some nasty workarounds.
In fact, this will fail even if you do not use vlcj, if you write the code yourself without using vlcj you are guaranteed to see the same failure.
The issue is caused by some combination of Java, VLC, LUA and 32-bit Ubuntu.
Probably the simplest workaround is to delete the VLC LUA scripts, but that will disable some functionality (such as YouTube).
There is a lot of background information here, way too much to reproduce in this answer:
https://github.com/caprica/vlcj/issues/62

Jet creator music - EAS synth.dll

I am trying to use the JET music player in Android to create music for my game. I am having trouble installing the eas synth plugin for Sonar 7 which I will use to edit the midi tracks.
I am using this guide to get everything installed so that I can edit my music.
The problem is at point 3.1 Installing the EAS Synth Plugin I am supposed to install EAS synth.dll into the Sonar vst plugin folder.
Where can i find the EAS synth.dll file? It is definitely not included in the SDK! I found a file called EADDLL.dll in the \tools\Jet\JetCreator directory, but Sonar does not recognize it as a plugin.
I think JET and JET creator is ridiculously pour documented by google! Any help regarding JET creator would be appreciated! I'm hoping for some smart guy here who has successfully used jet creator.
I had this problem as well. Very frustrating. The problem is that the included EASDLL.dll file is not actually a VST plugin. I wrote the a VST plugin that does the job and have published it here:
http://www.evanmallory.com/eas_vst/
Give it a try. I hope it will help you out.
*.dll files are for Windows only, the Linux equivalent is *.so, but the JET libraries area already installed on an Android device so you don't need to worry about it. As for Google's documentation, that link is not a Google page, here is the Google Documentation. Here is what it says:
Playing JET content The Android
platform includes a JET engine that
lets you add interactive playback of
JET audio content in your
applications. You can create JET
content for interactive playback using
the JetCreator authoring application
that ships with the SDK. To play and
manage JET content from your
application, use the JetPlayer class.
For a description of JET concepts and
instructions on how to use the
JetCreator authoring tool, see the
JetCreator User Manual. The tool is
available fully-featured on the OS X
and Windows platforms and the Linux
version supports all the content
creation features, but not the
auditioning of the imported assets.
Here's an example of how to set up JET
playback from a .jet file stored on
the SD card:
JetPlayer myJet = JetPlayer.getJetPlayer();
myJet.loadJetFile("/sdcard/level1.jet");
byte segmentId = 0;
// queue segment 5, repeat once, use General MIDI, transpose by -1 octave
myJet.queueJetSegment(5, -1, 1, -1, 0, segmentId++);
// queue segment 2
myJet.queueJetSegment(2, -1, 0, 0, 0, segmentId++);
myJet.play();
The SDK includes an example
application — JetBoy — that shows how
to use JetPlayer to create an
interactive music soundtrack in your
game. It also illustrates how to use
JET events to synchronize music and
game logic. The application is located
at
/platforms/android-1.5/samples/JetBoy.
I guess my question was a bit unclear...
I am trying to edit music on my computer using the music editing program Sonar 7. The music will be used in my game... In order to make the midi files compatible with android devices and JET Creator i need to use the EAS synth plugin for Sonar 7. The problem is that i cant find the "EAS Synth.dll" wich is needed for this. And yes, I have read trough all the documentation wich you are referring to :)
The plugin is described under section 3.1 in the guidelines:
http://www.netmite.com/android/mydroid/1.6/external/sonivox/docs/JET_Authoring_Guidelines.html

Java Sound API to access the system/master volume control in Vista and Win 7

History & Situation:
I'm currently working on updating a Java application that was developed for a client several years ago (to run on WinXP) and is used for testing and training people with certain hearing impairments. Users who bought this application were provided with a particular USB sound device and headphones.
One of the most important requirements for this software is that the audio must be played to the user at specific decibel sound levels. Using the Java Sound API, the application was developed to dynamically adjust the Windows Volume to calculated levels (based on measurements made when calibrating the USB sound device & headphones during development).
Problem:
The application now needs to be upgraded to support Windows Vista and Windows 7, however due to Windows' new per-app sound architecture, I've been unable to find any way to access the Master/System volume using the Java Sound API.
The application's windows volume control alone doesn't cut it since it's relative to the system volume and there's no way to guarantee that the user will hear the output audio at a specific, known level.
Does anybody know if it is even possible to do this in Java and if so then how? If it's not possible, then can you give any guidance on what might be the simplest way to achieve it? (JNI and C perhaps - though I've never used JNI before... any gotchas to be aware of?)
If you run your application in Windows XP compatibility mode, it should work (it depends on how the Java Sound API interacts with the hardware volume).
If you want to use the Vista (and beyond) sound APIs, you want to look at the IAudioEndpointVolume API.
My guess is since you're using an USB device, your Java sound API does not access the correct channel.
You can have a look at how to adjust the master volume in Windows XP. I know you aren't working in XP but have a look at how to access specific Lines and Mixers on that link. You may have to experiment a bit to find the correct line and mixer combination, or offer your users a GUI that allows them to choose the correct line and mixer combination.
I've run applications that work with this method in Windows 7 so I doubt that it's an O compatibility issue.

Sending MIDI messages in a Web page

How can I play individual MIDI notes in a Web page?
I know of two ways to do it:
Write an ActiveX control. Then it only works on Windows. I used to write ActiveX controls a long time ago, but now nobody likes to install them.
Write a Java applet. This is OK if the user already has Java installed, but many users disable applets. This is the way I did it and you can see the result at newfweiler.com -- if it happens to work on your particular setup. You'll need at least Java 5, although I suppose I could rewrite it in Java 1.2 if I had to. The "Real Time Sequencer" and "Java Sound Synthesizer" don't work for me; I think you have to install wavetables or something to make them work.
Most users have Flash installed, but I looked in the Flash and Flex documentation and did not see anything equivalent to javax.sound.midi.
There are several ways to play a MIDI file in a Web page, and you can find "Javascript Pianos" that play a one-note MIDI file whenever you press a key. You can't play multiple notes at once or hold the key down for a long note.
What I'm trying to do is the equivalent of javax.sound.midi.Receiver.send(midiMsg, -1) using only what most people typically have installed on the machine.
Use Web Audio API to play sounds and .mid-files. See example of MIDI player at https://surikov.github.io/webaudiofont/examples/midiplayer.html
Use Web MIDI API (Chrome supports it) to listen MIDI keyboard. See example at https://surikov.github.io/webaudiofont/examples/midikey.html
Java is still probably going to be your best bet, even with the few users disabling it.
I use NoScript, and I can whitelist a site. I would say that most users would probably do the same if you provide compelling content.
Found the following (translated from Italian). I'd say Flash is the way to go. If you want to be ghetto you can just get 88 or so piano samples and play them against a timeline.
http://translate.google.com/translate?prev=hp&hl=en&js=n&u=http%3A%2F%2Fflash.html.it%2Fguide%2Flezione%2F2936%2Fmidi-player%2F&sl=it&tl=en&history_state0=
There is an example of online MIDI piano at https://jazz-soft.net/demo/VirtualPiano.html
It uses the Web Audio API and does not require any special software, however, if the Web MIDI is enabled, it has more functionality. Code included on the page.

Categories