aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/songchange/songchange.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-01-13 15:40:30 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-01-13 15:40:30 +0000
commita4d4df97b77da4905ba4b4a14633f9241432f85c (patch)
tree2358675f56c19d61439de16300eb2c5743bf9403 /src/plugins/General/songchange/songchange.cpp
parentcf28884e3bf4edf48f6fa43fe075e7a1d279fd88 (diff)
downloadqmmp-a4d4df97b77da4905ba4b4a14633f9241432f85c.tar.gz
qmmp-a4d4df97b77da4905ba4b4a14633f9241432f85c.tar.bz2
qmmp-a4d4df97b77da4905ba4b4a14633f9241432f85c.zip
added complete song change plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3155 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/songchange/songchange.cpp')
-rw-r--r--src/plugins/General/songchange/songchange.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/plugins/General/songchange/songchange.cpp b/src/plugins/General/songchange/songchange.cpp
index 74aa6f4f8..0e79766de 100644
--- a/src/plugins/General/songchange/songchange.cpp
+++ b/src/plugins/General/songchange/songchange.cpp
@@ -26,6 +26,7 @@
#include <QMessageBox>
#include <QFile>
#include <QDir>
+#include <QProcess>
#include <qmmp/soundcore.h>
#include <qmmpui/uihelper.h>
#include <qmmpui/playlistmodel.h>
@@ -38,6 +39,7 @@
SongChange::SongChange(QObject *parent) : QObject(parent)
{
m_core = SoundCore::instance();
+ m_plManager = PlayListManager::instance();
connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(onStateChanged(Qmmp::State)));
connect(m_core, SIGNAL(metaDataChanged()), SLOT(onMetaDataChanged()));
connect(m_core, SIGNAL(finished()), SLOT(onFinised()));
@@ -69,11 +71,19 @@ void SongChange::onMetaDataChanged()
{
if(m_prevMetaData[Qmmp::URL] == metaData[Qmmp::URL])
{
- qDebug("m_titleChangeCommand");
+ if(!m_titleChangeCommand.isEmpty())
+ {
+ qDebug("SongChange: startig title change command..");
+ executeCommand(metaData, m_titleChangeCommand);
+ }
}
else
{
- qDebug("new_track_command");
+ if(!m_newTrackCommand.isEmpty())
+ {
+ qDebug("SongChange: startig new track command..");
+ executeCommand(metaData, m_newTrackCommand);
+ }
}
}
m_prevMetaData = metaData;
@@ -81,5 +91,28 @@ void SongChange::onMetaDataChanged()
void SongChange::onFinised()
{
- qDebug("on_track_finished");
+ if(!m_endOfTrackCommand.isEmpty())
+ {
+ qDebug("SongChange: startig end of track command..");
+ executeCommand(m_prevMetaData, m_endOfTrackCommand);
+ }
+ if(!m_endOfPlCommand.isEmpty() && !m_plManager->currentPlayList()->nextItem())
+ {
+ qDebug("SongChange: startig end of playlist command..");
+ executeCommand(m_prevMetaData, m_endOfPlCommand);
+ }
+}
+
+bool SongChange::executeCommand(const QMap<Qmmp::MetaData, QString> &metaData, const QString &format)
+{
+ MetaDataFormatter formatter(format);
+ QString command = formatter.parse(metaData);
+#ifdef Q_OS_WIN
+ bool ok = QProcess::startDetached(QString("cmd.exe \"%1\"").arg(command));
+#else
+ bool ok = QProcess::startDetached(QString("sh -c \"%1\"").arg(command));
+#endif
+ if(!ok)
+ qWarning("SongChange: unable to start command '%s'", qPrintable(command));
+ return ok;
}