If you install phonon, your package manager should install all dependencies as well. Actually I'm using xine backend for phonon on my Linux box and not gstreamer. I only had to install phonon-gstreamer and phonon-xine packages for both backends.
If you install phonon, your package manager should install all dependencies as well. Actually I'm using xine backend for phonon on my Linux box and not gstreamer. I only had to install phonon-gstreamer and phonon-xine packages for both backends.
hakermania (1st September 2010)
Thanks, but my package manager cannot find the files you specified. Also, what about QAudioOutput ? Can I play music with this?
I found a code and tranformed it (hehe) to this:
but the only output isQt Code:
#include <QFile> #include <QAudioFormat> #include <QAudioOutput> #include <QSound> int main() { QFile inputFile; inputFile.setFileName("/home/alex/Music/noh.wav"); QAudioFormat format; format.setFrequency(8000); format.setChannels(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleType(QAudioFormat::UnSignedInt); QAudioOutput *audio = new QAudioOutput( format, 0); audio->start(&inputFile); return 0; }To copy to clipboard, switch view to plain text mode
QObject::startTimer: QTimer can only be used with threads started with QThread and no sound is heard.. (--_--)
Well, obviously this won't work, especially if you exit the application immediately. Query your package manager for phonon and install everything related to it. You should at least get playback for the free formats (like ogg). Test it with the mediaplayer Qt example.
hakermania (1st September 2010)
Thank you. I installed Phonon and I tried the MediaPlayer example. unfortunately, even after the installation of all the codecs I can't still play mp3 files. This is quite embarrassing because there are some apps that support mp3 file playing, like Alarm Clock from the Software package manager in ubuntu... I downloaded the source but I didn't understand how does it do it haha.... anyway.... Is there any other other way to play mp3 files?
hakermania (1st September 2010)
Yes. i can play ogg and wav files. But I cannot play mp3 at all. All mp3 codecs need have been installed. We spoke about phonon and codecs that should be installed in this thread at post No#10 - post No#18
So, as Bong.Da.City has the same problem with me, I don't believe that there is a problem with the system codecs, as the necessary codecs have been installed. :/
If there is no solution on how to play mp3 files with phonon, I would like at least to know how to make the code that I posted above work and I'll use canberra-gtk-play (see post No#1 in this thread) as it supports wav and ogg files as well, so there is no point using phonon libraries as i have already include stdlib.h and i can call system() to play the sound....
Apparently not.
Run the phonon/capabilities example and see the list of supported file types.We spoke about phonon and codecs that should be installed in this thread at post No#10 - post No#18
So, as Bong.Da.City has the same problem with me, I don't believe that there is a problem with the system codecs, as the necessary codecs have been installed. :/
Bearing the fact that canberra-gtk-play probably uses gstreamer, the same as phonon that uses gstreamer, I don't really see the point of doing that. Phonon has nothing to do with the fact whether you can or cannot play mp3 files. If you can play anything then phonon works fine. Its work ends with passing the stream of bytes to gstreamer. By the way, you can also try the xine phonon backend from kde, maybe it'll work better for you. Also check if you can play the mp3 with totem as it has gstreamer as its backend too.If there is no solution on how to play mp3 files with phonon, I would like at least to know how to make the code that I posted above work and I'll use canberra-gtk-play (see post No#1 in this thread) as it supports wav and ogg files as well, so there is no point using phonon libraries as i have already include stdlib.h and i can call system() to play the sound....
I can play mp3 files with totem:
Although mp3 is not included in the list of files listed after the compilation of phonon/capabilities:
What should I doQt Code:
--ALSA-- annodex x-annodex aiff x-aiff x-pn-aiff flac x-flac x-realaudio basic x-basic x-pn-au x-mod mod it x-it x-stm x-s2m s3m med x-amf x-xm xm x-ogg ogg mp4 x-8svx 8svx 168sv x-ms-wma x-pn-realaudio x-pn-realaudio-plugin x-real-audio x-wav wav x-pn-wav x-pn-windows-acm musepack x-musepack x-wavpack x-flac flac x-vorbis+oggTo copy to clipboard, switch view to plain text mode
Did you try the xine backend? Also make sure you have ffmpeg and ffmpeg support for gstreamer installed if you are willing to continue with the gstreamer backend (provided you indeed have gstreamer as the backend). By the way, your list is very poor, mine is much richer.
hakermania (2nd September 2010)
There is also vlc and mplayer backeds, see:
http://www.gitorious.org/phonon
http://code.google.com/p/phonon-vlc-mplayer/
And maybe try running LiveCD Ubuntu (I assume, from the screens, that it's your Linux flavour) and mount partition with compiled examples and try installing there missing codec. It's just a thought but maybe You have broken dependences in Your system or "something strange" is going on. Test with native "Movie Player".
As said before, I installed (before posting) mentioned codec package in my Ubuntu and everything worked fine, same goes for Debian (although I had codec installed... well a long time ago).
hakermania (2nd September 2010)
There's nothing strange with my system. Bong.Da.City (I hope he'll post again because I need support here haha) has the same problem. Two same situations with the same problem in the same thread? I don't believe into such coincidences...Our systems haven't got any problem.
@wysota I installed them. MP3 still can't be played.
@Talei, I got errors when trying to install both phnon-vlc and phonon-mplayer when doing cmake..The output is:
VLC:
MPlayer:Qt Code:
alex@MaD-pc:~/phonon/phonon-vlc$ cmake vlc -- The C compiler identification is GNU -- The CXX compiler identification is GNU -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done CMake Error at CMakeLists.txt:45 (automoc4): Unknown CMake command "automoc4". CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 2.8) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it. -- Configuring incomplete, errors occurred! alex@MaD-pc:~/phonon/phonon-vlc$To copy to clipboard, switch view to plain text mode
Thx again.Qt Code:
-- The C compiler identification is GNU -- The CXX compiler identification is GNU -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done CMake Error at libmplayer/CMakeLists.txt:15 (qt4_wrap_cpp): Unknown CMake command "qt4_wrap_cpp". CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 2.8) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it. -- Configuring incomplete, errors occurred! alex@MaD-pc:~/phonon/phonon-mplayer$To copy to clipboard, switch view to plain text mode
You don't know he has the same problem. He has a similar problem. The reason might be completely different.
"Installing" is not enough. You have to make sure Phonon actually uses the other backend (you can temporarily move the gstreamer backend files elsewhere).@wysota I installed them. MP3 still can't be played.
Let's get one thing straight and I hope all people who are having problems with Phonon will read it very carefully and make sure they understand it.
To make Phonon work, three things have to happen simoultaneously:
1. Phonon library has to be compiled and installed together with all its dependencies. On Linux this is called libphonon.so and is usually located in /usr/lib (if installed for KDE) and/or $QTDIR/lib when installed by compiling Qt. On Windows this is phonon4.dll and probably resides in $QTDIR/bin. The library is responsible for providing an adapter between your code and phonon backend.
2. Phonon backend has to be compiled and installed together with all its dependencies. On Linux this is called libphonon_<X>.so where <X> can be one of {gstreamer,xine,vlc,mplayer} or possibly something else if a new backend is developed. The backend is located in /usr/lib/kde4/plugins/phonon_backend when installed for KDE and $QTDIR/plugins/phonon_backend when installed for Qt. On Windows this is called phonon_ds94.dll and is located in $QTDIR/plugins/phonon_backend. The backend is responsible for talking to the platform-dependent solution for playing multimedia such as gstreamer(0.10+) or xine on Linux, Direct Show on Windows and (AFAIR) Quick Time on MacOSX. The plugin has to be deployed with your application to the phonon_backend subdirectory to be able to play multimedia on target machines (unless you know there is a working phonon installation there, i.e. when using rpm and making sure KDE's Phonon is a dependency of your app).
3. Proper codecs, support files, etc. should be available for the solution used by Phonon backend.
On Unix...
...it is best to have ffmpeg installed which gives you access to /usr/lib/libavcodec and /isr/lib/libavformat. You can run ffmpeg -codecs to see available codecs built into the library. On different installations the list of codecs may be different as most Linux distros only enable so called Free (as in 'freedom of speech') codecs so i.e. flac might not be available. You can often install this library from a 3rd party vendor or non-free (as in 'freedom of speech') package source with additional (non-free) codecs enabled. But this might not enough to make media play in your apps. You often need to bind the codecs with the solution used by phonon backend:
For gstreamer you need to have gstreamer plugins installed (on my system (mdv) they are "gstreamer-plugins-base", "gstreamer-plugins-good", "gstreamer-plugins-bad" and "gstreamer-plugins-ugly" and also "gstreamer-ffmpeg" and a couple of others).
AFAIK Xine, MPlayer and VLC don't need any extra plugins, they will automatically pick up what's available on your system.
You can also install so called ''Windows codecs' which usually reside in /usr/lib/codecs or /usr/lib/win32 or in a similar location to get other proprietiary formats working. Getting ogg/ogv support might also be important (libvorbis/libtheora).
Also note that some codecs may require additional libraries, i.e. libflac
On Windows...
... you can install ffdshow which is the ffmpeg codec pack for Windows. The general rule is that whatever plays in Windows Media Player should play through Phonon too. The exception may be DRM-ed content, I don't know if that works.
You don't have much influence whether a particular file will play on some target system as you don't know if particular codecs are installed. Deploying them yourself is probably not a good idea (they might conflict with what the user already has in his system) so it's a better idea to use codecs and formats that are available by default in the target system. It is usually PCM (wav) for audio and mpeg-2 for video. It is not mp3 nor xvid/divx/mkv.
Troubleshooting
General rule #1: If anything (wav/ogg/mpeg-2) plays, then Phonon is installed correctly and items #1 and #2 from the above list are fulfilled. You are either missing codecs or plugins for your platform's multimedia solution. Unless you are sure a particular 3rd party player uses the same soolution for playback, testing the offending file with the player won't give you any meaningful results. Use the Phonon::BackendCapabilities class to see what should work with your current settings.
General rule #2: If you can't compile Phonon-based application or you can't execute it then you probably have problems with the (lib)phonon library (#1 from the above list). Check dependencies (ldd/dependency walker).
General rule #3: If you can't compile Phonon-based applications but Phonon examples can be executed correctly (regardless whether you get playback or not) then Phonon library is installed correctly but you are missing development files for Phonon (headers or import libraries).
General rule #4: Phonon can't be compiled statically into your application and in general Phonon will not work for statically built apps. Link your Phonon-based app dynamically.
General rule #5: If Phonon-based app compiles and runs but doesn't play any files (wav/ogg/mpeg-2) the problem is with the backend. Check if you have a backend installed (#2), verify its dependencies (ldd/dependency walker). You may try a different backend to see if it makes a difference. Use Phonon::BackendCapabilities to see what's available in your current settings. Sometimes it is good to rename phonon_backend directory to something else to see if Phonon starts complaining about no backend being available. Sometimes the backend may be taken from a different location than you expect. Same goes for the Phonon library. A useful tool for checking the backend is the KDE's system-settings application - go to its multimedia section to see what backends are available and which is the active one.
General rule #6: Phonon is not responsible for playback of multimedia files. It is responsible for talking with your platform's solution. If a particular file doesn't work, don't blame Phonon.
General rule #7: Check stupid mistakes such as permission problems (files, devices, resources) and spelling.
hakermania (2nd September 2010)
I installed libavformat and libacodec libraries and now mp3s can be played by the Phonon Music Player. The thing is, what dependencies have to include in my program in order to work in other PCs?
See the last paragraph of my post before the "troubleshooting" section.
hakermania (2nd September 2010)
Apf.. Too complicated.. Too hard! Check the backends, install the dependencies...And all these only for mp3 playing. Useless. I think I'll use the pre-installed canbera-gtk-play and have only ogg and wav support
My app wouldn't work in your system because it uses a lot of other bash commands like sed and other because this way is much easier than the C++ way (I mean for file processing). In order to play mp3 files, I found a terminal command called mpg123 only 35KB
But I do have sed installed on my system, so that's perfectly fine. I don't have your gtk player installed. I think I don't have mpg123 installed too, after all I have mplayer...
Edit: I do have mpg123. You should add another 250kB to your mpg123 as it requires the mpg123 library Dependencies, dependencies, dependencies...
Bookmarks