}
void MainWindow::createStatusBar() {
+ currentTime = new QLabel(this);
+ statusBar()->addPermanentWidget(currentTime);
+ totalTime = new QLabel(this);
+ statusBar()->addPermanentWidget(totalTime);
statusBar()->show();
}
void MainWindow::showSearch() {
showWidget(searchView);
+ currentTime->clear();
+ totalTime->clear();
}
void MainWindow::showMedia(QString query) {
case Phonon::LoadingState:
skipAct->setEnabled(true);
pauseAct->setEnabled(false);
+ currentTime->clear();
+ totalTime->clear();
break;
default:
if (mediaObject) delete mediaObject;
if (audioOutput) delete audioOutput;
mediaObject = new Phonon::MediaObject(this);
+ mediaObject->setTickInterval(100);
connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
this, SLOT(stateChanged(Phonon::State, Phonon::State)));
+ connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
+ connect(mediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64)));
seekSlider->setMediaObject(mediaObject);
audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
volumeSlider->setAudioOutput(audioOutput);
Phonon::createPath(mediaObject, audioOutput);
}
+
+void MainWindow::tick(qint64 time) {
+ QTime displayTime(0, (time / 60000) % 60, (time / 1000) % 60);
+ currentTime->setText(displayTime.toString("mm:ss"));
+ // qDebug() << "currentTime" << time << displayTime.toString("mm:ss");
+}
+
+void MainWindow::totalTimeChanged(qint64 time) {
+ if (time <= 0) {
+ totalTime->clear();
+ return;
+ }
+ QTime displayTime(0, (time / 60000) % 60, (time / 1000) % 60);
+ totalTime->setText(displayTime.toString("/ mm:ss"));
+ // qDebug() << "totalTime" << time << displayTime.toString("mm:ss");
+}
+
this, SLOT(stateChanged(Phonon::State, Phonon::State)));
connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)),
this, SLOT(currentSourceChanged(Phonon::MediaSource)));
- // connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
connect(mediaObject, SIGNAL(bufferStatus(int)), loadingWidget, SLOT(bufferStatus(int)));
}