Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
In Android, we can use the mediaplayer to play songs on the device, and cursors to get the track information (which the OS keeps track of). My question is, what are the Java equivalents of these?
Note: I have seen people mentioning JavaFX, however this does not seem to be installed with the JVM by default and thus my program would no longer be cross-platform.
Any suggestions?
Note: These will all be local files, though they may be of any audio filetype.
I'll provide information on a JavaFX related solution for a Java music player as I think it is a good technology to use for this task.
Supported Platforms and Formats
they may be of any audio filetype.
Supported audio types for JavaFX are documented in the javafx.scene.media javadoc. Supported formats for JavaFX 2.2 are MP3, AAC and PCM in various containers such as mp3, mp4 and wav files. Other formats such as Ogg Theora are not supported - so if you need such formats you will need a different solution than JavaFX 2.2.
I have seen people mentioning JavaFX, however this does not seem to be installed with the JVM by default and thus my program would no longer be cross-platform
JavaFX is installed with the Oracle Java runtime by default since Java 7 update 6 and JavaFX 2.2 runs on OS X, Windows and Linux. There are currently no widely available solutions for running JavaFX on mobile platforms (though that may change in the future).
Further information on using JavaFX with Java 7 is in my answer to Compiling and running with JavaFX 2.1 as well as the JavaFX Deployment Guide.
get the track information (which the OS keeps track of)
Most track information is actually encoded in media files rather than in an OS database. You can retrieve metadata from media files played by JavaFX. Parsing of a limited amount of metadata from media files is supported as defined in the media documentation. Note that not all media contains all metadata. I tested a free mp3 file from amazon and was able to extract plenty of metadata from it successfully. Metadata from a test aac encoded m4a file from iTunes was mostly empty. So results depend on the media file being used.
Sample Player
I created a sample music player in JavaFX which plays audio files from a directory, displaying metadata for each song.
java2s also host source for a media player created by the authors of the Pro JavaFX 2 book. That might be a better reference than my code, as mine was a quick hack, whereas the pro source is from a professionally published book.
Additional Questions
Any suggestions for those of us on linux not using Oracle's JRE?
Oracle JRE is available on Linux, but if you don't want to use that, you can build openjfx for openjdk and use that, or you could develop your app using Oracle JRE and use the JavaFX packaging tools to distribute it as a self-contained application so it has no external JRE dependency.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
There is a way to put a computer program with .exe extensions in the Android program and then run them through the program.
I have read about ndk and win, but I do not know exactly how to use them
Please describe with an example or give full reference
You are trying to run a binary application (intel x86 .exe for windows) on a different architecture and platform (android running on ARM or Arch64).
I can think of three options:
Option 1: Emulation
The traditional approach to running binaries for different architectures is emulation, for example using Qemu.
However, that still leaves the different platform. If your exe file uses a GUI and a filesystem, for example, you suddenly also need to emulate parts of the operating system it expects, or ship a copy of some Windows variant with your application, which would have all kinds of copyright constraints.
Finally, keep in mind that Android devices have completely different input mechanism than a traditional Windows PC, so you would have to link the Android virtual keyboard (and touch events) to a keyboard and mouse for the emulated Windows PC.
This is not impossible, but will require a tremendous amount of supporting code.
If you choose to go this route, I suggest you first buy a desktop-like ARM device like a Raspberry Pi and get it working there.
Option 2: Decompilation and porting to Android
You can find decompilers that turn the .exe file back into a set of compilable C or C++ files. This would allow you to carefully extract the functionality you need and wrap it in Android native code. This was how OpenRCT2 and Diablo were ported to other platforms like Linux and macOS, years later.
You should not expect the decompiled source code to resemble anything you would write yourself, but with enough time you can end up with something Android-native (or linux, or macOS, or even iOS).
Option 3: Host the application elsewhere
Finally, you could opt to NOT port the application to Android at all, but rather host it on a Windows machine you can run 24/7, and make it accessible on your phone. Depending on the application, this could take the form of a web service that runs the .exe with input from the web, or a full-blown remote desktop/VNC session where you can interact with the application using your phone's input methods.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I see the statement below on Google in one form or another
Most of the Android development is Java based because Android supports
a large number of Java libraries
I am coming from Java based web application background. I have never heard the statement "Windows supports one specific language but Linux does not". Then why in context of mobile OS we say android supports Java. The role of any OS is to execute the commands and not to support the specific language, right?
I know I am missing something basic here, but what's that?
Then why in context of mobile OS we say android support java.
I do not know who "we" is. Experienced computer programmers would not say that, and even your made-up quote does not say that.
Role of any OS is to execute the commands not to support the specific language right ?
Correct. And, given a rooted Android device, you are welcome to try porting any language you like to Android, and in a custom ROM mod, you are welcome to arrange to allow the user to run any program they want in any of those supported languages.
However, most people do not have rooted Android devices.
On a normal Android device, the Android frameworks put some limitations on what you easily can use for programming.
For example, you can divide the world of Java-capable servers into two main categories:
Those where you have complete control over the server, which is roughly equivalent to running a rooted Android device
Those where all you can do is upload a WAR and related files (e.g., static assets), which are run on a Java-powered server managed by somebody else
In that latter scenario, you are not going to have complete flexibility in programming. Presumably, you could integrate JVM-based scripting languages, but you may have difficulty in using C++. That is not an issue with the OS — the server itself is probably perfectly capable of running a C++ program. It is an issue of the framework in which your code is running (whatever people use for WARs nowadays, as it has been a long time since I worked in server-side Java development).
The primary framework for Android development is based on Java. Courtesy of WebView, this also opens up hooks for hybrid development (HTML/CSS/JS). NativeActivity makes it possible to write full Android apps in C/C++. Various toolchains allow you to write in other languages (e.g., Kotlin) that compile into something that works with Android's frameworks, and you can embed scripting languages. But you still need to stick to the frameworks, which puts some limits on what you can do and how you can do it. This is not the fault of the Android OS, but rather the frameworks.
Yes, Android is based on Java. But recently the grandpa Delphi acquired fire monkey, which is supposed to transform Delphi code in to native Android code. That way it supposedly run just like a native application.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
In Android, we can use the mediaplayer to play songs on the device, and cursors to get the track information (which the OS keeps track of). My question is, what are the Java equivalents of these?
Note: I have seen people mentioning JavaFX, however this does not seem to be installed with the JVM by default and thus my program would no longer be cross-platform.
Any suggestions?
Note: These will all be local files, though they may be of any audio filetype.
I'll provide information on a JavaFX related solution for a Java music player as I think it is a good technology to use for this task.
Supported Platforms and Formats
they may be of any audio filetype.
Supported audio types for JavaFX are documented in the javafx.scene.media javadoc. Supported formats for JavaFX 2.2 are MP3, AAC and PCM in various containers such as mp3, mp4 and wav files. Other formats such as Ogg Theora are not supported - so if you need such formats you will need a different solution than JavaFX 2.2.
I have seen people mentioning JavaFX, however this does not seem to be installed with the JVM by default and thus my program would no longer be cross-platform
JavaFX is installed with the Oracle Java runtime by default since Java 7 update 6 and JavaFX 2.2 runs on OS X, Windows and Linux. There are currently no widely available solutions for running JavaFX on mobile platforms (though that may change in the future).
Further information on using JavaFX with Java 7 is in my answer to Compiling and running with JavaFX 2.1 as well as the JavaFX Deployment Guide.
get the track information (which the OS keeps track of)
Most track information is actually encoded in media files rather than in an OS database. You can retrieve metadata from media files played by JavaFX. Parsing of a limited amount of metadata from media files is supported as defined in the media documentation. Note that not all media contains all metadata. I tested a free mp3 file from amazon and was able to extract plenty of metadata from it successfully. Metadata from a test aac encoded m4a file from iTunes was mostly empty. So results depend on the media file being used.
Sample Player
I created a sample music player in JavaFX which plays audio files from a directory, displaying metadata for each song.
java2s also host source for a media player created by the authors of the Pro JavaFX 2 book. That might be a better reference than my code, as mine was a quick hack, whereas the pro source is from a professionally published book.
Additional Questions
Any suggestions for those of us on linux not using Oracle's JRE?
Oracle JRE is available on Linux, but if you don't want to use that, you can build openjfx for openjdk and use that, or you could develop your app using Oracle JRE and use the JavaFX packaging tools to distribute it as a self-contained application so it has no external JRE dependency.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am evaluating libraries for playing audio/video in Java. It does not need to be 100% Java; Java bindings to native libraries are perfectly OK. An external application that can be controlled from Java is also fine, as long as it can render video on a Java component.
The target platform is Linux. Windows support is a plus, but not required.
I have played with VLC using the VLCj bindings, and it works pretty well in general, but keeps crashing occasionally when put under stress. I have also used mplayer in slave mode, which looks good. But I'd like to evaluate other options as well.
These are the requirements:
Live playback of H.264, MPEG4 through RTP using RTSP. Extra points for MJPEG over HTTP.
Able to render video on a Java (Swing or AWT) Component
Open source, and actively maintained
Stable, rock-solid
Suggestions? Advice?
Ok, I've spent the last month playing with several options and these are the results:
VLC. This was my first thought, as everybody keeps saying that it "plays everything". I have used both the VLCj Java bindings, and the built-in remote interface (-I rc). I found this to work pretty well in general, but had some issues. I kept seeing ocassional crashes under heavy load (not VLCj's fault as it also happens when using the binary directly). Also I've found memory consumption to be relatively high when compared to other options.
MPlayer. This actually performs better than VLC in my experience, no crashes, and memory consumption is lower. No Java bindings, although the slave mode works very well.
GStreamer. Very powerful, very flexible, while still easy to get started with. Tried both the Java bindings and running the gst-launch binary from Java. Both approaches work remarkably well.
Xuggler looked good, however it seems to have issues with RTP (as stated in the FAQ). Since both GStreamer and MPlayer worked so well, I did not get past the initial research.
I found GStreamer to be the best solution given the requirements, with MPlayer being the second option.
have you looked at gstreamer?
I've also spent a while researching my options, and I've actually come to the conclusion that VLCJ is the best option - however here's the clincher, you need to run it out of process (especially with multiple players) for it to give you 100% reliable operation. That's the approach I'm taking and I've yet to see it crash. With it rock solid in this way it also has other advantages:
It can play pretty much anything. Yes it's a bit of a cliche, but this includes DVDs, Youtube videos, pretty much any video file...
Should support Linux / Mac / Windows, though I've yet to verify Mac working.
Actively maintained, and if you ask a good (as in well thought out) question on the discussion group the owner often replies in minute in my experience!
Open source, and the Google group activity at the time of writing is high.
Uses all the graphics acceleration VLC does
Able to play to any heavyweight Canvas component (and if you use the direct player, you get the BufferedImage to display anywhere you like, even in JOGL 3D land if you're that crazy!
I haven't found it that heavy on the resources front either, though I haven't done any thorough testing (but 3 players work fine in tandem as well as my relatively power-hungry application on my 4 year old basic laptop!)
Disadvantages? There's no official framework for out of process players, so you have to build one yourself (see here for how I did it). And you do sometimes have to do some fiddling to get it working. But as far as I can see, it's working well for me so far!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Can anyone suggest a good open-source image processing library in Java?
I want to develop an OMR reader using it.
There are a number of options out there, each with their own features and drawbacks. If you want to discuss your needs in more detail, I can touch on the specific attributes of each library as it relates to your project:
ImageJ - http://rsbweb.nih.gov/ij/index.html -- Note that ImageJ is primarily a self-contained application. However, the underlying API is very easy to use in your own applications without having to invoke the GUI.
Fiji - http://pacific.mpi-cbg.de/wiki/index.php/Main_Page -- This is ImageJ with a number of additional features. I have no personal experience with this library, but it looks promising.
JAI - http://www.oracle.com/technetwork/articles/javaee/jai-142803.html -- This is Sun's image processing Java offering. Limited in functionality, but it can be used as a basis for more powerful libraries.
jMagick - http://www.jmagick.org/index.html -- This is just a Java wrapper around ImageMagick and uses JNI to interface with the ImageMagick API
Apache Sanselan - http://commons.apache.org/imaging/ -- This library mostly does image IO, but it has a handful of features that can facilitate image analysis.
JIU (Java Imaging Utilities) - http://sourceforge.net/projects/jiu/ -- A Java library for loading, editing, analyzing and saving pixel image files.
Endrov - http://www.endrov.net/wiki/index.php?title=Main_Page -- Endrov is a multi-purpose image analysis program. I get the impression that the underlying API is usable outside of the application, but it also seems that not everything is implemented in Java. I have no personal experience with this library and am only throwing it in because it seems to have a number of useful features.
JAI
Marvin Image Processing Framework
http://marvinproject.sourceforge.net
and the dead-simple one: imgscalr
I would suggest using JAI, as mentioned, for the imaging side, but for writing an OMR application you will need template registration. This can be achieved using OpenCv. This works with Java (as well as many other languages and platforms).
Without good image registration, regardless of image processing library, you will end up missing some of the marks on some scans, as you will find that some scans are shifted due to the way scanners work.