the following code plays the song while a button is pressed (onclick
). I have created a horizontalSlider
UI but it is not sliding. I got the documen开发者_JS百科t from http://wiki.forum.nokia.com/index.php/Streaming_Audio_with_Qt
Please help me to make the slider work.
Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
Phonon::AudioOutput *audioOutput =
new Phonon::AudioOutput(Phonon::MusicCategory, this);
Phonon::createPath(mediaObject, audioOutput);
const QString url("c://example.mp3");
mediaObject->setCurrentSource(url);
mediaObject->play();
volumeSlider = new Phonon::VolumeSlider(ui->horizontalSlider);
volumeSlider->setAudioOutput(audioOutput);
volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
Probably you didn't bind the corresponding media object to the slider.
See a small example here.
精彩评论