lupo5
11th May 2014, 20:43
Hi everyone,
Is this possible?
Im trying:
bool MainWindow::on_checkBox_clicked()
{
QString alarmTime = QString::number(this->ui->timeEdit->time().hour()) + QString::number(this->ui->timeEdit->time().minute());
QString currentTime = QString::number(QTime::currentTime().hour()) + QString::number(QTime::currentTime().minute());
QMediaPlaylist *playlist = new QMediaPlaylist(this);
playlist->addMedia(QUrl::fromLocalFile("/path/song.mp3"));
playlist->setPlaybackMode(QMediaPlaylist::Loop);
playlist->setCurrentIndex(1);
QMediaPlayer *player = new QMediaPlayer(this);
player->setPlaylist(playlist);
player->setVolume(100);
if(this->ui->checkBox_2->isChecked() == false)
{
if(alarmTime == currentTime)
{
player->play();
}
}
else
if(this->ui->checkBox_2->isChecked() == true)
{
playlist->stop();
}
}
It starts playing fine, but when I click the appropriate check box to stop it, it does not. Any thoughts on how I can get this to work properly?
Thank you!!!
Is this possible?
Im trying:
bool MainWindow::on_checkBox_clicked()
{
QString alarmTime = QString::number(this->ui->timeEdit->time().hour()) + QString::number(this->ui->timeEdit->time().minute());
QString currentTime = QString::number(QTime::currentTime().hour()) + QString::number(QTime::currentTime().minute());
QMediaPlaylist *playlist = new QMediaPlaylist(this);
playlist->addMedia(QUrl::fromLocalFile("/path/song.mp3"));
playlist->setPlaybackMode(QMediaPlaylist::Loop);
playlist->setCurrentIndex(1);
QMediaPlayer *player = new QMediaPlayer(this);
player->setPlaylist(playlist);
player->setVolume(100);
if(this->ui->checkBox_2->isChecked() == false)
{
if(alarmTime == currentTime)
{
player->play();
}
}
else
if(this->ui->checkBox_2->isChecked() == true)
{
playlist->stop();
}
}
It starts playing fine, but when I click the appropriate check box to stop it, it does not. Any thoughts on how I can get this to work properly?
Thank you!!!