Skip to content

Commit

Permalink
Improved video error message display
Browse files Browse the repository at this point in the history
  • Loading branch information
vladozar committed Sep 12, 2017
1 parent b1a3907 commit 062c967
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 35 deletions.
22 changes: 13 additions & 9 deletions mediacontrol.ui
Expand Up @@ -21,14 +21,21 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSlider" name="horizontalSliderTime">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSlider" name="horizontalSliderTime">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelTime"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButtonStop">
<property name="text">
Expand Down Expand Up @@ -85,9 +92,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelTime"/>
</item>
</layout>
</item>
</layout>
Expand Down
40 changes: 31 additions & 9 deletions mediawidget.cpp
Expand Up @@ -50,6 +50,7 @@ MediaWidget::MediaWidget(QWidget *parent) :


connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), mediaControls, SLOT(updatePlayerState(QMediaPlayer::State)));
connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));
connect(player, SIGNAL(durationChanged(qint64)), mediaControls, SLOT(setMaximumTime(qint64)));
connect(player, SIGNAL(positionChanged(qint64)), mediaControls, SLOT(updateTime(qint64)));
connect(player, SIGNAL(volumeChanged(int)),mediaControls,SLOT(setVolume(int)));
Expand Down Expand Up @@ -127,23 +128,44 @@ void MediaWidget::loadMediaLibrary()
}
}


void MediaWidget::statusChanged(QMediaPlayer::MediaStatus status)
{
switch (status) {
case QMediaPlayer::InvalidMedia:
qDebug()<<"InvalidMedia: "<<player->errorString();
ui->labelInfo->setText(QString("<center><strong><font color=#ff5555>%1:</font></strong><br>"
"<font color=#49fff9>%2</font><br>%3.</center>")
.arg(tr("ERROR Playing media file"))
.arg(currentMediaUrl.fileName())
.arg(tr("It is possible that SoftProjector does not support given media format")));
case QMediaPlayer::BufferingMedia:
case QMediaPlayer::LoadingMedia:
ui->labelInfo->setText(QString("<center><strong><font color=#49fff9>%1</font>")
.arg(tr("Loading...")));
break;
default:
case QMediaPlayer::StalledMedia:
ui->labelInfo->setText(QString("<center><strong><font color=#49fff9>%1</font>")
.arg(tr("Media Stalled")));
break;
case QMediaPlayer::InvalidMedia:
displayErrorMessage();
break;
}
}

void MediaWidget::displayErrorMessage()
{
QString errMsg1 = tr("Possible Fail reasons:");
QString errMsg2 = tr(" - Unsupported media format");
QString errMsg3 = tr(" - Media file no longer existn or invalid path to file");

if(!player->errorString().isEmpty())
{
errMsg1 = player->errorString();
errMsg2 = errMsg3 = "";
}
ui->labelInfo->setText(QString("<center><strong><font color=#ff5555>%1:</font></strong><br>"
"<font color=#49fff9>%2</font><br>%3<br>%4<br>%5</center>")
.arg(tr("ERROR Playing media file"))
.arg(currentMediaUrl.fileName())
.arg(errMsg1)
.arg(errMsg2)
.arg(errMsg3));
}

void MediaWidget::handleDrop(QDropEvent *e)
{
QList<QUrl> urls = e->mimeData()->urls();
Expand Down
1 change: 1 addition & 0 deletions mediawidget.hpp
Expand Up @@ -67,6 +67,7 @@ private slots:
void handleDrop(QDropEvent *e);
void loadMediaLibrary();
void statusChanged(QMediaPlayer::MediaStatus status);
void displayErrorMessage();

void hasVideoChanged(bool);
void insertFiles(QStringList &files);
Expand Down
17 changes: 0 additions & 17 deletions softprojector.cpp
Expand Up @@ -965,23 +965,6 @@ void SoftProjector::updateEditActions()
/////////////////////////////////////////
// Set Print Action Menu enabled
ui->actionPrint->setEnabled(ctab == 0 || ctab == 1 || ctab == 4);

// // Set Edit Action Menu Visibility
// ui->actionNew->setVisible(ctab == 1 || ctab == 2 || ctab == 3 );
// ui->actionEdit->setVisible(ctab == 1 || ctab == 2 || ctab == 3);
// ui->actionCopy->setVisible(ctab == 1 || ctab == 3);
// ui->actionDelete->setVisible(ctab == 0 || ctab == 1 || ctab == 2 || ctab == 3 );

// // Set Edit Action Menu enabled
// ui->actionNew->setEnabled(ctab == 1 || ctab == 2 || ctab == 3);
// ui->actionEdit->setEnabled(ctab == 1 || ctab == 2 || ctab == 3);
// ui->actionCopy->setEnabled(ctab == 1 || ctab == 3);
// ui->actionDelete->setEnabled(ctab == 0 || ctab == 1 || ctab == 2 || ctab == 3);

// /////////////////////////////////////////
// // Set Print Action Menu enabled
// ui->actionPrint->setEnabled(ctab == 0 || ctab == 1 || ctab == 3);

}

void SoftProjector::on_actionNew_triggered()
Expand Down

0 comments on commit 062c967

Please sign in to comment.