Results 1 to 5 of 5

Thread: How to set volume of phonon audio output

  1. #1
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default How to set volume of phonon audio output

    Qt Code:
    1. Musicvalue="Sounds/yellow.mp3";
    2. audioOutputmusic = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    3. mediaObjectmusic = new Phonon::MediaObject(this);
    4. mediaObjectmusic->setCurrentSource(Phonon::MediaSource(Musicvalue));
    5. Phonon::createPath(mediaObjectmusic, audioOutputmusic);
    6. audioOutputmusic->setVolume(1.0);
    7. mediaObjectmusic->play();
    To copy to clipboard, switch view to plain text mode 


    But there is no change in volume

  2. #2
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to set volume of phonon audio output

    k i got it.

  3. #3
    Join Date
    Sep 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set volume of phonon audio output

    Hi athulms,

    I'm experiencing the same problem, did you find out how to make it work?

  4. #4
    Join Date
    Oct 2011
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to set volume of phonon audio output

    hi,athulms

    Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider(this);
    volumeSlider->setAudioOutput(audioOutputmusic); // set audio output device
    volumeSlider->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::M aximum);


    and now,you can change the volume use the slider.also,you can overwrite the wheelEvent function as follow:

    // wheelEvent
    void musicPlayer::wheelEvent(QWheelEvent *wheelEvent)
    {
    if(wheelEvent->delta() > 0 ) // trun up
    {
    qreal newVolume = audioOutputmusic->volume() + (qreal)0.05;
    if(newVolume >= (qreal)1)
    newVolume = (qreal)1;
    audioOutputmusic->setVolume(newVolume);
    }
    else // trun down
    {
    qreal newVolume = audioOutputmusic->volume() - (qreal)0.05;
    if(newVolume <= (qreal)0)
    newVolume = (qreal)0;
    audioOutputmusic->setVolume(newVolume);
    }

    }
    Last edited by Mr.Simple; 6th October 2011 at 16:51.

  5. #5
    Join Date
    Nov 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to set volume of phonon audio output

    Hi!

    I am trying with your example and it is not working.

    Do i have to connect any action to work with the wheelEvent? Or just to create that function as slot?

    Also, i want to ask, if there are any way to know if my mp3 file is not loaded, cuz, i don't know how to do the control error.

    thanks in advance

Similar Threads

  1. Phonon - audio-output-problem and high latency
    By nearlyNERD in forum Qt Programming
    Replies: 3
    Last Post: 27th June 2012, 22:17
  2. Replies: 0
    Last Post: 4th August 2011, 12:25
  3. Phonon and Volume Slider (Nokia N8)
    By abashir in forum Newbie
    Replies: 0
    Last Post: 6th January 2011, 23:46
  4. Phonon - Audio-Output-Problem
    By nearlyNERD in forum Newbie
    Replies: 4
    Last Post: 19th July 2010, 11:52
  5. Handle windows audio volume
    By Raccoon29 in forum General Programming
    Replies: 7
    Last Post: 6th December 2009, 23:41

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.