Results 1 to 20 of 39

Thread: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    Same problem here... I finally managed tto install phonon and compile the application... Thanks to hakermania.. Anyway it doesn't play mp3 files.. I also have those packets you mentioned before....

    gstreamer0.10-ffmpeg
    gstreamer0.10-fluendo-mp3
    gstreamer0.10-plugins-ugly

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    Can you play those mp3 files using pure gstreamer? Please also note that Phonon requires particular version of gstreamer (as mentioned in the docs).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    Yeah. I can listen to mp3 files through pure gstremer. So, Phonon has a lot of dependencies as I understood. This means that it is not so useful because users that will use my app would have to download and install all these packages in order to Phonon to work, right?... How about using QAudioOutput? What does it support?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    hakermania (1st September 2010)

  6. #5
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    Thanks, but my package manager cannot find the files you specified. Also, what about QAudioOutput ? Can I play music with this?

  7. #6
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    I found a code and tranformed it (hehe) to this:
    Qt Code:
    1. #include <QFile>
    2. #include <QAudioFormat>
    3. #include <QAudioOutput>
    4. #include <QSound>
    5.  
    6. int main()
    7. {
    8. QFile inputFile;
    9. inputFile.setFileName("/home/alex/Music/noh.wav");
    10. inputFile.open(QIODevice::ReadOnly);
    11.  
    12. QAudioFormat format;
    13. format.setFrequency(8000);
    14. format.setChannels(1);
    15. format.setSampleSize(8);
    16. format.setCodec("audio/pcm");
    17. format.setByteOrder(QAudioFormat::LittleEndian);
    18. format.setSampleType(QAudioFormat::UnSignedInt);
    19. QAudioOutput *audio = new QAudioOutput( format, 0);
    20. audio->start(&inputFile);
    21. return 0;
    22. }
    To copy to clipboard, switch view to plain text mode 
    but the only output is
    QObject::startTimer: QTimer can only be used with threads started with QThread and no sound is heard.. (--_--)

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    hakermania (1st September 2010)

  10. #8
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    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?

  11. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    Quote Originally Posted by hakermania View Post
    unfortunately, even after the installation of all the codecs I can't still play mp3 files
    Can you play ogg files? Or any other kinds of files?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    hakermania (1st September 2010)

  13. #10
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    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....

  14. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    Quote Originally Posted by hakermania View Post
    All mp3 codecs need have been installed.
    Apparently not.

    We spoke about phonon and codecs that should be installed in this thread at post No#10 - post No#18
    Run the phonon/capabilities example and see the list of supported file types.

    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....
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #12
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to play MP3,WAV,OGG,FLAC,MP4,M4A ?

    I can play mp3 files with totem:

    Although mp3 is not included in the list of files listed after the compilation of phonon/capabilities:
    Qt Code:
    1. --ALSA--
    2. annodex
    3. x-annodex
    4. aiff
    5. x-aiff
    6. x-pn-aiff
    7. flac
    8. x-flac
    9. x-realaudio
    10. basic
    11. x-basic
    12. x-pn-au
    13. x-mod
    14. mod
    15. it
    16. x-it
    17. x-stm
    18. x-s2m
    19. s3m
    20. med
    21. x-amf
    22. x-xm
    23. xm
    24. x-ogg
    25. ogg
    26. mp4
    27. x-8svx
    28. 8svx
    29. 168sv
    30. x-ms-wma
    31. x-pn-realaudio
    32. x-pn-realaudio-plugin
    33. x-real-audio
    34. x-wav
    35. wav
    36. x-pn-wav
    37. x-pn-windows-acm
    38. musepack
    39. x-musepack
    40. x-wavpack
    41. x-flac
    42. flac
    43. x-vorbis+ogg
    To copy to clipboard, switch view to plain text mode 
    What should I do

Similar Threads

  1. Play .amr sound
    By ahmdsd_ostora in forum Qt Programming
    Replies: 3
    Last Post: 17th July 2010, 15:34
  2. play audio url
    By tungvc in forum Qt Programming
    Replies: 0
    Last Post: 15th July 2010, 11:04
  3. qmake flac
    By rubenvb in forum Qt Programming
    Replies: 0
    Last Post: 8th November 2009, 15:18
  4. To Play Movie in QT 4
    By Isa in forum Qt Programming
    Replies: 8
    Last Post: 2nd August 2008, 11:56
  5. QPicture does not play right
    By derick in forum Qt Programming
    Replies: 5
    Last Post: 19th February 2006, 01:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.