PDA

View Full Version : How to set volume of phonon audio output



athulms
12th September 2011, 09:14
Musicvalue="Sounds/yellow.mp3";
audioOutputmusic = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mediaObjectmusic = new Phonon::MediaObject(this);
mediaObjectmusic->setCurrentSource(Phonon::MediaSource(Musicvalue));
Phonon::createPath(mediaObjectmusic, audioOutputmusic);
audioOutputmusic->setVolume(1.0);
mediaObjectmusic->play();


But there is no change in volume

athulms
12th September 2011, 11:44
k i got it.

silvana
23rd September 2011, 01:27
Hi athulms,

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

Mr.Simple
6th October 2011, 15:43
hi,athulms

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

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);
}

}

fri
9th November 2011, 09:38
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