Friday, October 24, 2008

Qt and Phonon, or how to compile a pre-written application with the use of Google

I've been using XMMS for a long while now. When it comes to playing music, it does about everything I want, but its looks aren't the greatest. JuK and/or amaroK on the other hand, have a reasonably nice, but clogged UI, and I don't need them storing all information about my music if I have that myself anyway.
Hence, I thought about writing a simple Qt-based media player myself which would contain nothing more or less than what I wanted. A secondary and not less important goal being to get some experience with Qt.
For starters, the Qt 4 documentation contains a working media player that uses Phonon as a backend. So why not compile that, see how it works, and tweak some things, gradually learning?

So, let's start by grabbing the sources... by copying the text out of the manual, since I can't find the source files themselves, and apparently the qt4-examples package has been missing in action since quite a while in Debian.
Next step: put those files in a folder and compile. Of course, compiling simply by running g++ does not work. Should have known, but my hacking skills are a bit rusty. Instead, I have to run qmake, errm, I mean qmake-qt4.
Then run make, having made sure that all Phonon include files can be found.

Finally! It runs! But no music yet... I have to install the Phonon backend first. Silly me for thinking that installing the Phonon libraries and development packages would install the backend, which is required to be actually able to do anything with your newly compiled application, as well.
So now it should work, right? Oh, wait. It is not yet available at the expected location. And after that... Hurray!

I have to admit, once it works, it works like a charm, and the code is actually quite legible even though I have little knowledge of Qt (and C++, for that matter). But the process to get it working was a bit too bumpy to my taste.

1 comment:

Unknown said...

Hi,

interesting article, could you provide the complete source-code?

So that I don't need to do all the steps?

Thanks,
Sven