Results 1 to 4 of 4

Thread: Phonon and simple player...

  1. #1
    Join Date
    Mar 2011
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Phonon and simple player...

    i want to make a simple console mp3 player. I want my program to take a name of the music file in console as a paramenter argv[]. But i have a problem:

    Qt Code:
    1. #include <QCoreApplication>
    2. #include <phonon/AudioOutput>
    3. #include <phonon/MediaObject>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QCoreApplication app(argc, argv);
    8.  
    9. Phonon::MediaObject obj;
    10. Phonon::AudioOutput out;
    11.  
    12. obj.setCurrentSource(Phonon::MediaSource(argv[1])); //!!!!!!!!!!!!!!
    13. Phonon::createPath(&obj, &out);
    14. obj.play();
    15.  
    16. return app.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 


    the problem is here
    Qt Code:
    1. obj.setCurrentSource(Phonon::MediaSource(argv[1])); //!!!!!!!!!!!!!!
    To copy to clipboard, switch view to plain text mode 

    i think it is because MediaSource takes CONST QSTRING & parameter
    but i do not know what to do! help me please!
    Last edited by wysota; 6th March 2011 at 21:33. Reason: missing [code] tags

  2. #2
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Phonon and simple player...

    QString foo = argv[1];

    That's one possible way to get a QString from a char*

  3. #3
    Join Date
    Mar 2011
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Phonon and simple player...

    Quote Originally Posted by megazig View Post
    QString foo = argv[1];

    That's one possible way to get a QString from a char*
    no that also does not work... i use mingw and during compilling i get this:

    Qt Code:
    1. PS C:\my\cbp> make
    2. mingw32-make -f Makefile.Debug
    3. mingw32-make[1]: Entering directory `C:/my/cbp'
    4. g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_
    5. HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\Qt\
    6. 4.7.1\include\QtCore" -I"..\..\Qt\4.7.1\include\QtGui" -I"..\..\Qt\4.7.1\include" -I"." -I"..\..\Qt\4.7.1\include\Active
    7. Qt" -I"debug" -I"..\..\Qt\4.7.1\mkspecs\default" -o debug\main.o main.cpp
    8. g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows
    9. -o debug\cbp.exe debug/main.o -L"c:\Qt\4.7.1\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
    10. debug/main.o: In function `main':
    11. C:\my\cbp/main.cpp:12: undefined reference to `_imp___ZN6Phonon11MediaObjectC1EP7QObject'
    12. C:\my\cbp/main.cpp:13: undefined reference to `_imp___ZN6Phonon11AudioOutputC1EP7QObject'
    13. C:\my\cbp/main.cpp:17: undefined reference to `_imp___ZN6Phonon11MediaSourceC1ERK7QString'
    14. C:\my\cbp/main.cpp:17: undefined reference to `_imp___ZN6Phonon11MediaObject16setCurrentSourceERKNS_11MediaSourceE'
    15. C:\my\cbp/main.cpp:17: undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'
    16. C:\my\cbp/main.cpp:18: undefined reference to `_imp___ZN6Phonon10createPathEPNS_9MediaNodeES1_'
    17. C:\my\cbp/main.cpp:18: undefined reference to `_imp___ZN6Phonon4PathD1Ev'
    18. C:\my\cbp/main.cpp:19: undefined reference to `_imp___ZN6Phonon11MediaObject4playEv'
    19. C:\my\cbp/main.cpp:12: undefined reference to `_imp___ZN6Phonon11MediaObjectD1Ev'
    20. C:\my\cbp/main.cpp:17: undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'
    21. C:\my\cbp/main.cpp:12: undefined reference to `_imp___ZN6Phonon11MediaObjectD1Ev'
    22. debug/main.o: In function `~AudioOutput':
    23. C:\my\cbp/../../Qt/4.7.1/include/phonon/../../src/phonon/../3rdparty/phonon/phonon/audiooutput.h:51: undefined reference
    24. to `_imp___ZTVN6Phonon11AudioOutputE'
    25. C:\my\cbp/../../Qt/4.7.1/include/phonon/../../src/phonon/../3rdparty/phonon/phonon/audiooutput.h:51: undefined reference
    26. to `_imp___ZTVN6Phonon11AudioOutputE'
    27. C:\my\cbp/../../Qt/4.7.1/include/phonon/../../src/phonon/../3rdparty/phonon/phonon/audiooutput.h:51: undefined reference
    28. to `_imp___ZN6Phonon19AbstractAudioOutputD2Ev'
    29. collect2: ld returned 1 exit status
    30. mingw32-make[1]: *** [debug\cbp.exe] Error 1
    31. mingw32-make[1]: Leaving directory `C:/my/cbp'
    32. mingw32-make: *** [debug] Error 2
    To copy to clipboard, switch view to plain text mode 

    i even tried to write
    Qt Code:
    1. const QString foo = argv[1];
    To copy to clipboard, switch view to plain text mode 
    maybe there is another way to make such program...
    help me please!

  4. #4
    Join Date
    Jan 2011
    Location
    Pearl of the Orient Seas
    Posts
    40
    Thanks
    12
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: Phonon and simple player...

    and i shall answer my own question, such a noob i finally found the answer after a lot of googling..

    i did not include phonon in the .pro file..

    this solved my problem:
    Qt Code:
    1. QT += network xml webkit phonon
    To copy to clipboard, switch view to plain text mode 

    you only have to include the things you need.

    @make i hope this will help you too
    Last edited by aya_lawliet; 8th March 2011 at 13:06. Reason: updated contents

Similar Threads

  1. Phonon Player Disappears When resizing/repainting
    By saltman in forum Qt Programming
    Replies: 0
    Last Post: 18th November 2010, 20:44
  2. Phonon Video Player Problem...
    By emrez in forum Qt Programming
    Replies: 0
    Last Post: 14th July 2010, 15:26
  3. Replies: 0
    Last Post: 8th April 2010, 03:39
  4. Phonon Video Player + XML
    By igor.schkrab in forum Qt Programming
    Replies: 0
    Last Post: 25th November 2009, 00:49
  5. problem with phonon/music player example.
    By rishiraj in forum Newbie
    Replies: 9
    Last Post: 23rd January 2009, 09:00

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.