Java and music player

Today I found post on elliotth's blog about Java and MP3. Being developer of Xine engine for aTunes I have own thoughts about it.

Step 1: Target users
At first you should decide who will be your users. Depending on this choice you have different amount of possibilities. For example, Qt Jambi with Phonon will fit for all systems, while Xine is not available for M$Windows users.

Step 2: Engine
Second part of music player is engine. I am long time SUSE user and I prefer Xine over other because it ships with SUSE and all best KDE apps are using it as engine. Also popular MPlayer, VLC and Gstreamer. Of course I hate Gstreamer because of strange format support politics and trashy sound, but it's your own choice.

Step 3: How to use engine
After you decided what engine you want to use - there is a question how to use it.

a) JNI
You can use some wrapper generator like SWIG to generate wrappers and use it from your application. While this is the fastest way to invoke engine - there are few possible problems:
1. You have to build your application for all platforms yourself. It can be hard enough if you have no compilers for target platform and you have never used some of target platforms, or you have only 32bit CPU.
2. Static vs dynamic linking. I am not C/C++ guru, but I noticed that some apps build on other systems than mine can't find libs from system folders like /usr/lib. It's easy to understand that there are some linking problems for target platform depending on libs path or libs versions.

b) JNA
It's my favorite. JNA guys did a great job. They solved all possible problems in JNI approach, building jna.jar for all platforms and supporting dynamic linking. The only problem - mostly you have to read *.h files and write classes to wrap them. It is simple if you know a bit of C/C++.

c) cmd line
You always can invoke your engine from command line. MPlayer have it's own command line interface, so you can just send commands and read responses from Process stream. Also, Amarok supports commands like "amarok -s" to stop. May be your favorite player also does? Of course you should give user to choose path to your supported engine, while Linux platforms can be found in $PATH it will not work on M$Windows.

d) Use Qt Jambi
I already wrote about Qt Jambi. It's great solution for any desktop application, not just music player. And it have it's own media API, that can be found in examples. I suggest you to download and take a look yourself.

e) choose from existing wrappers
Many engines have it's own wrappers already. Here are some of them:

No comments: