/* if media file is specified on cmd line, use it */
QStringList args = QApplication::arguments(); if (args.count() > 1)
{ if (QFile::exists(args.at(1)))
{
interface->setFilename(args.at(1));
filename = args.at(1);
gotMediaOnCmdline = true;
on_actionOpen_Media_File_triggered();
} else
{
QMessageBox::warning(this, "Invalid media file specified", "\nThe media file\n\n" + args.at(1) + "\n\ndoes not exist");
}
}
}
void MainWindow::closeEvent(QCloseEvent *event)
{ if (oneTimeInitSuccess)
{
interface->deInitRemoteClient();
} else
{
QMessageBox::warning(this, "Closing application", "This is not an xrdp session with xrdpvr");
}
event->accept();
}
/* setup area to display video */
lblVideo = new QLabel();
lblVideo->setMinimumWidth(320);
lblVideo->setMinimumHeight(200);
QPalette palette = lblVideo->palette();
palette.setColor(lblVideo->backgroundRole(), QColor(0x00, 0x00, 0x01, 0xff));
palette.setColor(lblVideo->foregroundRole(), QColor(0x00, 0x00, 0x01, 0xff));
lblVideo->setAutoFillBackground(true);
lblVideo->setPalette(palette);
hboxLayoutTop = new QHBoxLayout;
hboxLayoutTop->addWidget(lblVideo);
/* setup label to display current pos in media */
lblCurrentPos = new QLabel("00:00:00");
lblCurrentPos->setMinimumHeight(20);
lblCurrentPos->setMaximumHeight(20);
/* setup slider to seek into media */
slider = new QSlider();
slider->setOrientation(Qt::Horizontal);
slider->setMinimumHeight(20);
slider->setMaximumHeight(20);
connect(slider, SIGNAL(actionTriggered(int)), this, SLOT(onSliderActionTriggered(int)));
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
/* setup label to display media duration */
lblDuration = new QLabel("00:00:00");
lblDuration->setMinimumHeight(20);
lblDuration->setMaximumHeight(20);
/* add above three widgets to mid layout */
hboxLayoutMiddle = new QHBoxLayout;
hboxLayoutMiddle->addWidget(lblCurrentPos);
hboxLayoutMiddle->addWidget(slider);
hboxLayoutMiddle->addWidget(lblDuration);
/* setup play button */
btnPlay = new QPushButton("Play");
btnPlay->setMinimumHeight(40);
btnPlay->setMaximumHeight(40);
btnPlay->setMinimumWidth(40);
btnPlay->setMaximumWidth(40);
btnPlay->setCheckable(true);
connect(btnPlay, SIGNAL(clicked(bool)), this, SLOT(onBtnPlayClicked(bool)));
/* add all three layouts to one vertical layout */
vboxLayout = new QVBoxLayout;
vboxLayout->addLayout(hboxLayoutTop);
vboxLayout->addLayout(hboxLayoutMiddle);
vboxLayout->addLayout(hboxLayoutBottom);
/* add all of them to central widget */
window = new QWidget;
window->setLayout(vboxLayout); this->setCentralWidget(window);
}
void MainWindow::openMediaFile()
{ /* TODO take last stored value from QSettings */
if (filename.length() == 0)
{
/* no previous selection - open user's home folder TODO */ // TODO filename = QFileDialog::getOpenFileName(this, "Select Media File", "/"); //filename = QFileDialog::getOpenFileName(this, "Select Media File", // QDir::currentPath());
/* clear screen by filling it with black */
usleep(500 * 1000);
clearDisplay();
btnPlay->setChecked(false);
}
void MainWindow::onMediaDurationInSeconds(int duration)
{ int hours = 0; int minutes = 0; int secs = 0; char buf[20];
/* setup progress bar */
slider->setMinimum(0);
slider->setMaximum(duration * 100); /* in hundredth of a sec */
slider->setValue(0);
slider->setSliderPosition(0);
lblCurrentPos->setText("00:00:00"); //qDebug() << "media_duration=" << duration << " in hundredth of a sec:" << duration * 100;
/* convert from seconds to hours:minutes:seconds */
hours = duration / 3600; if (hours)
duration -= (hours * 3600);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.