]> git.sesse.net Git - kdenlive/commitdiff
Fix freesound autoplay
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 30 Dec 2011 09:51:01 +0000 (10:51 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 30 Dec 2011 09:51:01 +0000 (10:51 +0100)
src/utils/freesound.cpp
src/utils/freesound.h

index 542549fdc67620d87d5a088b99e07da786a4334d..bf313d49d35c5ca5e87eb14237a0fc719f4fc676 100644 (file)
@@ -81,6 +81,7 @@ FreeSound::FreeSound(const QString & folder, QWidget * parent) :
     connect(page_next, SIGNAL(clicked()), this, SLOT(slotNextPage()));
     connect(page_prev, SIGNAL(clicked()), this, SLOT(slotPreviousPage()));
     connect(page_number, SIGNAL(valueChanged(int)), this, SLOT(slotStartSearch(int)));
+    sound_box->setEnabled(false);
 }
 
 FreeSound::~FreeSound()
@@ -194,7 +195,7 @@ void FreeSound::slotShowResults()
 
 void FreeSound::slotUpdateCurrentSound()
 {
-    if (!sound_autoplay->isChecked()) slotPlaySound(false);
+    if (!sound_autoplay->isChecked()) slotForcePlaySound(false);
     m_currentPreview.clear();
     m_currentUrl.clear();
     QListWidgetItem *item = search_results->currentItem();
@@ -204,7 +205,7 @@ void FreeSound::slotUpdateCurrentSound()
     }
     m_currentPreview = item->data(previewRole).toString();
     m_currentUrl = item->data(downloadRole).toString();
-    if (sound_autoplay->isChecked()) slotPlaySound(true);
+    if (sound_autoplay->isChecked()) slotForcePlaySound(true);
     button_preview->setEnabled(!m_currentPreview.isEmpty());
     sound_box->setEnabled(true);
     sound_name->setText(item->text());
@@ -233,17 +234,26 @@ void FreeSound::slotUpdateCurrentSound()
     }
 }
 
-
-void FreeSound::slotPlaySound(bool play)
+void FreeSound::slotPlaySound()
 {
     if (m_currentPreview.isEmpty()) return;
-    if (!play || (m_previewProcess && m_previewProcess->state() != QProcess::NotRunning)) {
+    if (m_previewProcess && m_previewProcess->state() != QProcess::NotRunning) {
         m_previewProcess->close();
-        if (!play) return;
+        return;
     }
     m_previewProcess->start("ffplay", QStringList() << m_currentPreview << "-nodisp");
 }
 
+
+void FreeSound::slotForcePlaySound(bool play)
+{
+    if (m_service != FREESOUND) return;
+    m_previewProcess->close();
+    if (m_currentPreview.isEmpty()) return;
+    if (play)
+        m_previewProcess->start("ffplay", QStringList() << m_currentPreview << "-nodisp");
+}
+
 void FreeSound::slotPreviewStatusChanged(QProcess::ProcessState state)
 {
     if (state == QProcess::NotRunning)
index ca397b0f8e4a52671ff09c327f83b046383bebae..48fbfaed4c511d6c2b07d76ca84a587d5941479f 100644 (file)
@@ -45,7 +45,8 @@ private slots:
     void slotDataIsHere(KIO::Job *,const QByteArray & data );
     void slotShowResults();
     void slotUpdateCurrentSound();
-    void slotPlaySound(bool play = true);
+    void slotPlaySound();
+    void slotForcePlaySound(bool play);
     void slotPreviewStatusChanged(QProcess::ProcessState state);
     void slotSaveSound();
     void slotOpenUrl(const QString &url);