Added own button for play with Qt media player

Added own button for play with Qt media player
This commit is contained in:
defnax 2020-02-07 16:33:26 +01:00
parent 8dd85f2391
commit 8cce8cbbe5
3 changed files with 54 additions and 27 deletions

View File

@ -99,6 +99,7 @@ SubFileItem::SubFileItem(const RsFileHash &hash, const std::string &name, const
void SubFileItem::Setup()
{
connect( playButton, SIGNAL( clicked( ) ), this, SLOT( play ( ) ) );
connect( mediaplayerButton, SIGNAL( clicked( ) ), this, SLOT( playmedia ( ) ) );
connect( downloadButton, SIGNAL( clicked( ) ), this, SLOT( download ( ) ) );
connect( cancelButton, SIGNAL( clicked( ) ), this, SLOT( cancel( ) ) );
connect( deleteButton, SIGNAL( clicked( ) ), this, SLOT( del( ) ) );
@ -589,9 +590,41 @@ void SubFileItem::play()
QFileInfo qinfo;
qinfo.setFile(info.path.c_str());
if (qinfo.exists()) {
MainWindow::showWindow(MainWindow::Player);
PlayerPage *Player = dynamic_cast<PlayerPage*>(MainWindow::getPage(MainWindow::Player));
Player->setUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()));
if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
std::cerr << "openTransfer(): can't open file " << info.path << std::endl;
}
}else{
QMessageBox::information(this, tr("Play File"),
tr("File %1 does not exist at location.").arg(info.path.c_str()));
return;
}
} else {
/* rise a message box for incompleted download file */
QMessageBox::information(this, tr("Play File"),
tr("File %1 is not completed.").arg(info.fname.c_str()));
return;
}
}
void SubFileItem::playmedia()
{
FileInfo info;
FileSearchFlags flags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE;
if (!rsFiles->FileDetails( mFileHash, flags, info))
return;
if (done()) {
/* Play the Video with the Qt Mediaplayer */
QFileInfo qinfo;
qinfo.setFile(info.path.c_str());
if (qinfo.exists()) {
MainWindow::showWindow(MainWindow::Player);
PlayerPage *Player = dynamic_cast<PlayerPage*>(MainWindow::getPage(MainWindow::Player));
Player->setUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()));
}else{
QMessageBox::information(this, tr("Play File"),
tr("File %1 does not exist at location.").arg(info.path.c_str()));

View File

@ -82,6 +82,7 @@ public slots:
void play();
void mediatype();
void copyLink();
void playmedia();
private slots:
void toggle();

View File

@ -70,12 +70,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@ -96,12 +90,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@ -117,6 +105,23 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mediaplayerButton">
<property name="toolTip">
<string>Play in Qt Media Player</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/video-camera.png</normaloff>:/icons/png/video-camera.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="playButton">
<property name="sizePolicy">
@ -125,12 +130,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@ -180,12 +179,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>