Results 1 to 20 of 23

Thread: volume control

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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

  2. #2
    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?

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

  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

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

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

  6. #6
    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?

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

  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

    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 ?

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

    Default Re: volume control

    hi
    i only posted the reqired code. this is my full code:
    form1.cpp
    Qt Code:
    1. #include "form1.h"
    2. #include "ui_form1.h"
    3.  
    4. #include "form2.h"
    5.  
    6. #include <QPixmap>
    7. #include <QPalette>
    8. #include <QDesktopWidget>
    9. #include <QRect>
    10. #include <QSize>
    11. #include <QApplication>
    12.  
    13. //#include <QIcon>
    14.  
    15. #include <QMouseEvent>
    16.  
    17.  
    18. #include <phonon/MediaObject>
    19. #include <phonon/AudioOutput>
    20. #include <phonon/VolumeSlider>
    21. #include <QLibrary>
    22. #include <windows.h>
    23.  
    24. Form1::Form1(QWidget *parent) :
    25. QWidget(parent),
    26. ui(new Ui::Form1)
    27. {
    28. ui->setupUi(this);
    29.  
    30. connect(ui->pushButton_24,SIGNAL(clicked()),this,SLOT(showMinimized()));
    31.  
    32. // These three line is used for remove 'window title bar'
    33. this->setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
    34. this->setWindowFlags(Qt::CustomizeWindowHint);
    35. this->setWindowFlags(Qt::FramelessWindowHint);
    36.  
    37.  
    38. //this->setWindowFlags(Qt::SplashScreen);
    39.  
    40. //background image using 'pixmap' and 'palette'
    41. this->setFixedSize(270,350);
    42.  
    43. QPixmap pixmap1("E:/workplace/image/two.JPG");
    44. QPalette p = palette();
    45.  
    46. //resize image if it is larger than screen size.
    47. QDesktopWidget* desktopWidget = QApplication::desktop();
    48. QRect rect = desktopWidget->availableGeometry();
    49.  
    50. QSize size(rect.width() , rect.height());
    51. //resize as per your requirement..
    52. //QPixmap pixmap(pixmap1.scaled(size));
    53. QPixmap pixmap(pixmap1.scaled(270,350));
    54.  
    55. p.setBrush(QPalette::Background, pixmap);
    56. setPalette(p);
    57.  
    58. //ui->pushButton->setIcon(QIcon("E:/workplace/image/01.gif"));
    59.  
    60.  
    61. //connect(ui->horizontalSlider,SIGNAL(volumeChanged(Phonon::MediaObject,Phonon::AudioOutput)),
    62. //this,SLOT(setVolumeDecibel(Phonon::MediaObject,Phonon::AudioOutput)));
    63.  
    64.  
    65. QLibrary myLib("C:/Windows/System32/MMSYSTEM.DLL");
    66.  
    67. myLib.load();
    68.  
    69. if (myLib.isLoaded())
    70. {
    71. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),this,SLOT(setAudioOutput()));
    72. }
    73.  
    74. //Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    75. //Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
    76. //Phonon::createPath(mediaObject, audioOutput);
    77. //mediaObject->setCurrentSource(Phonon::MediaSource("C:/Windows/Suiystem32/MMSYSTEM.DLL"));
    78. //Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;
    79. //volumeSlider->setAudioOutput(audioOutput);
    80.  
    81. }
    82.  
    83. Form1::~Form1()
    84. {
    85. delete ui;
    86. }
    87.  
    88. void Form1::one()
    89. {
    90. text1+="1";
    91. //text1+=ui->pushButton->text();
    92. ui->lineEdit->setText(text1);
    93. }
    94.  
    95. void Form1::two()
    96. {
    97. text1+="2";
    98. //text1+=ui->pushButton_4->text();
    99. ui->lineEdit->setText(text1);
    100. }
    101.  
    102. void Form1::three()
    103. {
    104. text1+="3";
    105. //text1+=ui->pushButton_3->text();
    106. ui->lineEdit->setText(text1);
    107. }
    108.  
    109. void Form1::four()
    110. {
    111. text1+="4";
    112. //text1+=ui->pushButton_2->text();
    113. ui->lineEdit->setText(text1);
    114. }
    115.  
    116. void Form1::five()
    117. {
    118. text1+="5";
    119. //text1+=ui->pushButton_5->text();
    120. ui->lineEdit->setText(text1);
    121. }
    122.  
    123. void Form1::six()
    124. {
    125. text1+="6";
    126. //text1+=ui->pushButton_6->text();
    127. ui->lineEdit->setText(text1);
    128. }
    129.  
    130. void Form1::seven()
    131. {
    132. text1+="7";
    133. //text1+=ui->pushButton_7->text();
    134. ui->lineEdit->setText(text1);
    135. }
    136.  
    137. void Form1::eight()
    138. {
    139. text1+="8";
    140. //text1+=ui->pushButton_8->text();
    141. ui->lineEdit->setText(text1);
    142. }
    143.  
    144. void Form1::nine()
    145. {
    146. text1+="9";
    147. //text1+=ui->pushButton_9->text();
    148. ui->lineEdit->setText(text1);
    149. }
    150.  
    151. void Form1::star()
    152. {
    153. text1+="*";
    154. //text1+=ui->pushButton_10->text();
    155. ui->lineEdit->setText(text1);
    156. }
    157.  
    158. void Form1::zero()
    159. text1+="0";
    160. //text1+=ui->pushButton_11->text();
    161. ui->lineEdit->setText(text1);
    162. }
    163.  
    164. void Form1::hash()
    165. {
    166. text1+="#";
    167. //text1+=ui->pushButton_12->text();
    168. ui->lineEdit->setText(text1);
    169. }
    170.  
    171. void Form1::clear()
    172. {
    173. text1 = "";
    174. ui->lineEdit->clear();
    175. }
    176.  
    177. void Form1::showForm2()
    178. {
    179. Form2 *frm2 = new Form2;
    180. frm2->show();
    181. //this->close();
    182. //this->destroy();
    183.  
    184. }
    185.  
    186.  
    187. void Form1::closeSecondWindow()
    188. {
    189. this->close();
    190. }
    191.  
    192. void Form1::mouseMoveEvent(QMouseEvent *event)
    193. {
    194. if (event->buttons() & Qt::LeftButton)
    195. {
    196. move(event->globalPos() - m_dragPosition);
    197. event->accept();
    198. }
    199. }
    200. void Form1::mousePressEvent(QMouseEvent *event)
    201. {
    202. if (event->button() == Qt::LeftButton)
    203. {
    204. m_dragPosition = event->globalPos() - frameGeometry().topLeft();
    205. event->accept();
    206. }
    207. }
    To copy to clipboard, switch view to plain text mode 

    i have another form named form2.this is not matter. i need to access the windows volume control with sliders(horizontal slider)
    Last edited by masuk; 6th February 2011 at 12:35.

  10. #10
    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 don't see any code for accessing windows volume control, and I don't see any definitions for Form2, which is probably why the compiler is complaining.

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

    Default Re: volume control

    i can't get any solution for control system volume level. as phonon use only for control application volume.i need source code how to control system(xp,vista,linux) volume using slider(horizontal slider).

    thanks

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.