Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: volume control

  1. #1
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default volume control

    hi

    i want to display windows volume control wizard with a button click. i also want to control volume (microphone and speaker) using slider.how to do these??

    advance thanx

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: volume control

    You could implement the IAudioVolumeLevel interface?

    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

  3. #3
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    how to implement??
    give some link or reference.

    thanks

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: volume control

    I included a link/reference in my post. Perhaps you missed it?

  5. #5
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    how to implement in qt??

  6. #6
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: volume control

    hi masuk,

    In windows XP u can use windows.h (api)

    hope it helps
    Bala

  7. #7
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    hi bala
    can you give sample source code??
    Last edited by masuk; 2nd February 2011 at 11:38.

  8. #8
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: volume control

    You implement as per any other COM object, using REFIID IID_IAudioVolumeLevel.

    If you don't want the complexity of COM objects, then the best thing to do is just alter your own volume output only, rather than trying to adjust the system volume.

  9. #9
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    hi all,

    i need Qt documentation/samples to solve.

    thanks

  10. #10
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: volume control

    i need Qt documentation/samples to solve.
    You mean you want working code ?

  11. #11
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    I need Qt documentation. how can i add windows api,how to adjust with slider.

    thanks

  12. #12
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: volume control

    You can use windows API calls in the same way regardless of whether you use Qt or not, as Qt is just another library that you use, like Win API.

    Qt itself does not support altering the system volume control.

  13. #13
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    i tried this
    Qt Code:
    1. #include "form1.h"
    2. #include "ui_form1.h"
    3.  
    4. #include <phonon/AudioOutput>
    5. #include <phonon/MediaObject>
    6. #include <phonon/VolumeSlider>
    7.  
    8. Form1::Form1(QWidget *parent) :
    9. QWidget(parent),
    10. ui(new Ui::Form1)
    11. {
    12. ui->setupUi(this);
    13.  
    14. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),this,SLOT(setAudioOutput()));
    15.  
    16. Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    17. Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
    18. Phonon::createPath(mediaObject, audioOutput);
    19.  
    20. Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;
    21. volumeSlider->setAudioOutput(audioOutput);
    22. }
    To copy to clipboard, switch view to plain text mode 

    but showing these errors:
    Qt Code:
    1. cpp:59: undefined reference to `_imp___ZN6Phonon11MediaObjectC1EP7QObject'
    2.  
    3. cpp:60: undefined reference to `_imp___ZN6Phonon11AudioOutputC1ENS_8CategoryEP7QObject'
    4.  
    5. cpp:61: undefined reference to `_imp___ZN6Phonon10createPathEPNS_9MediaNodeES1_'
    6.  
    7. cpp:61: undefined reference to `_imp___ZN6Phonon4PathD1Ev'
    8.  
    9. cpp:63: undefined reference to `_imp___ZN6Phonon12VolumeSliderC1EP7QWidget'
    10.  
    11. cpp:64: undefined reference to `_imp___ZN6Phonon12VolumeSlider14setAudioOutputEPNS_11AudioOutputE'
    12.  
    13. cpp:59: undefined reference to `_imp___ZN6Phonon11MediaObjectC1EP7QObject'
    14.  
    15. cpp:60: undefined reference to `_imp___ZN6Phonon11AudioOutputC1ENS_8CategoryEP7QObject'
    16.  
    17. cpp:61: undefined reference to `_imp___ZN6Phonon10createPathEPNS_9MediaNodeES1_'
    18.  
    19. cpp:61: undefined reference to `_imp___ZN6Phonon4PathD1Ev'
    20.  
    21. cpp:63: undefined reference to `_imp___ZN6Phonon12VolumeSliderC1EP7QWidget'
    22.  
    23. cpp:64: undefined reference to `_imp___ZN6Phonon12VolumeSlider14setAudioOutputEPNS_11AudioOutputE'
    24.  
    25. collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    Is possible to solve in this way?

    thanks

  14. #14
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: volume control

    did you made changes to your .pro file to link to phonon?

  15. #15
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    hi
    thanks nish.
    after link to phonon there is no error. but i can not solve my problem means when i moved slider(horizontal slider) it does not change the volume level of "windows volume control"

    thanks

  16. #16
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: volume control

    That is correct, phonon only changes the volume control of application. To change the system volume control, it is more difficult and requires WinAPI.

  17. #17
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    i tried this
    Qt Code:
    1. #include "form1.h"
    2. #include "ui_form1.h"
    3.  
    4. #include <phonon/AudioOutput>
    5. #include <phonon/MediaObject>
    6. #include <phonon/VolumeSlider>
    7. #include <QLibrary>
    8. #include <windows.h>
    9.  
    10. Form1::Form1(QWidget *parent) :
    11. QWidget(parent),
    12. ui(new Ui::Form1)
    13. {
    14. ui->setupUi(this);
    15. QLibrary myLib("C:/Windows/System32/MMSYSTEM.DLL");
    16.  
    17. myLib.load();
    18.  
    19. if (myLib.isLoaded())
    20. {
    21. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),this,SLOT(setAudioOutput()));
    22. }
    23.  
    24. //Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    25. //Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
    26. //Phonon::createPath(mediaObject, audioOutput);
    27. //mediaObject->setCurrentSource(Phonon::MediaSource("C:/Windows/Suiystem32/MMSYSTEM.DLL"));
    28. //Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;
    29. //volumeSlider->setAudioOutput(audioOutput);
    30. }
    31.  
    32. void Form1::showForm2() //<----error show here
    33. {
    34. Form2 *frm2 = new Form2; //<----error show here
    35. frm2->show(); //<----error show here
    36. }
    To copy to clipboard, switch view to plain text mode 

    As phonon only changes the volume control of application so i comments those lines.

    But when use #include<windows.h> these errors shown:
    Qt Code:
    1. form1.cpp: In member function 'void Form1::showForm2()':
    2.  
    3. form1.cpp:182: error: expected unqualified-id before numeric constant
    4.  
    5. form1.cpp:182: error: expected initializer before numeric constant
    6.  
    7. form1.cpp:183: error: base operand of '->' is not a pointer
    To copy to clipboard, switch view to plain text mode 

    this is .pro file
    Qt Code:
    1. QT += core gui
    2. QT += phonon
    3.  
    4. LIBS += -luser32 -lshell32 -lgdi32
    5.  
    6. TARGET = untitled2
    7. TEMPLATE = app
    8.  
    9.  
    10. SOURCES += main.cpp\
    11. mainwindow.cpp \
    12. form1.cpp
    13.  
    14. HEADERS += mainwindow.h \
    15. form1.h
    16.  
    17. FORMS += mainwindow.ui \
    18. form1.ui
    To copy to clipboard, switch view to plain text mode 

    my problem is not solved."is the signal and slot is right that i used for horizontal slider" and "is the selected .dll is right to solve my problem"?

    thanks
    Last edited by masuk; 6th February 2011 at 06:34.

  18. #18
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: volume control

    Where is Form2 defined?

  19. #19
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: volume control

    Hi squidge

    actually in my program i defined #include "form2.h" but in post that missed.
    Qt Code:
    1. #include "form1.h"
    2. #include "ui_form1.h"
    3. #include "form2.h"
    4. #include <phonon/AudioOutput>
    5. #include <phonon/MediaObject>
    6. #include <phonon/VolumeSlider>
    7. #include <QLibrary>
    8. #include <windows.h>
    9.  
    10. Form1::Form1(QWidget *parent) :
    11. QWidget(parent),
    12. ui(new Ui::Form1)
    13. {
    14. ui->setupUi(this);
    15. QLibrary myLib("C:/Windows/System32/MMSYSTEM.DLL");
    16.  
    17. myLib.load();
    18.  
    19. if (myLib.isLoaded())
    20. {
    21. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),this,SLOT(setAudioOutput()));
    22. }
    23.  
    24. //Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    25. //Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
    26. //Phonon::createPath(mediaObject, audioOutput);
    27. //mediaObject->setCurrentSource(Phonon::MediaSource("C:/Windows/Suiystem32/MMSYSTEM.DLL"));
    28. //Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;
    29. //volumeSlider->setAudioOutput(audioOutput);
    30. }
    31.  
    32. void Form1::showForm2() //<----error show here
    33. {
    34. Form2 *frm2 = new Form2; //<----error show here
    35. frm2->show(); //<----error show here
    36. }
    To copy to clipboard, switch view to plain text mode 

    but my problem is not solved.....

    thanks

  20. #20
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: volume control

    Ok, I'm confused. The error is on line 182, but there are only 36 lines in your post.

    Secondly, what is content of Form2.h ?

Similar Threads

  1. Sound Volume
    By anafor2004 in forum Qt for Embedded and Mobile
    Replies: 7
    Last Post: 2nd February 2011, 06:03
  2. Replies: 0
    Last Post: 16th December 2009, 09:45
  3. How to get the Volume name from QFileDialog?
    By vishal.chauhan in forum Qt Programming
    Replies: 0
    Last Post: 30th August 2008, 12:28
  4. Volume control for Windows XP
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2007, 06:18
  5. Volume Render
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2006, 10:04

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.