PDA

View Full Version : play muisc with QPhonon and QTimer



vanduongbk
17th July 2014, 06:36
hello all
I have a question how I can play music in slot with timer
I test in main programming and music nice play ,but I can not test loop with Qtimer ,
this is my code ,plz help

main:


ui->setupUi(this);
mediaObject = new Phonon::MediaObject(this);
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mediaObject->setCurrentSource(Phonon::MediaSource("/home/beep.wav"));
Phonon::createPath(mediaObject, audioOutput);
mediaObject->play(); //play
m_timer =new QTimer(this);
connect(m_timer,SIGNAL(timeout()),this,SLOT(play_m usic()));
m_timer->start(1000);




void MainWindow::play_music()
{
mediaObject->setCurrentSource(Phonon::MediaSource("/home/beep.wav"));
mediaObject->play();
}