Hello list,
I was searching for a way to load files from extern (e.g. from command
line or by DBus) into one deck of Mixxx.
Thanks to using the Qt library adding this feature needs only a few
lines as in the attached patch.
It makes two functions callable from extern. One for checking if the
deck is currently playing. The other for
loading a file into one deck.
This patch was generated on top of the 1.11.0 release (from
git://github.com/ywwg/mixxx-trunk.git).
It was only compiled on linux. This patch is only useful if there is a
DBus implementation available and/or
has probably to be disabled on Windows and OS X.
Is there a chance to get something like this included?
Kind regards,
Bernhard
>From 2083a15a07178872869e52ffddc4137c6e48dcba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= <bernha...@vr-web.de>
Date: Thu, 16 May 2013 14:32:42 +0200
Subject: [PATCH] Expose a simple DBus-Interface to load files into decks from
extern.
---
mixxx/build/depends.py | 1 +
mixxx/src/main.cpp | 17 +++++++++++++++++
mixxx/src/mixxx.h | 2 ++
mixxx/src/playermanager.cpp | 10 ++++++++++
mixxx/src/playermanager.h | 9 ++++++++-
5 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/mixxx/build/depends.py b/mixxx/build/depends.py
index d209ff8..4611868 100644
--- a/mixxx/build/depends.py
+++ b/mixxx/build/depends.py
@@ -220,6 +220,7 @@ class Qt(Dependence):
build.env.Append(LIBS = 'QtXml')
build.env.Append(LIBS = 'QtNetwork')
build.env.Append(LIBS = 'QtScript')
+ build.env.Append(LIBS = 'QtDBus')
if use_qtwebkit:
build.env.Append(LIBS = 'QtWebKit')
elif build.platform_is_windows:
diff --git a/mixxx/src/main.cpp b/mixxx/src/main.cpp
index 3c5995d..0befeb9 100644
--- a/mixxx/src/main.cpp
+++ b/mixxx/src/main.cpp
@@ -17,6 +17,7 @@
#include <QThread>
#include <QDir>
+#include <QtDBus>
#include <QtDebug>
#include <qapplication.h>
#include <qfont.h>
@@ -35,6 +36,7 @@
#include "qsplashscreen.h"
#include "errordialoghandler.h"
#include "defs_version.h"
+#include "playermanager.h"
#ifdef __LADSPA__
#include <ladspa/ladspaloader.h>
@@ -281,8 +283,23 @@ int main(int argc, char * argv[])
}
#endif
+ if (!QDBusConnection::sessionBus().isConnected()) {
+ fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
+ "To start it, run:\n"
+ "\teval `dbus-launch --auto-syntax`\n");
+ return 1;
+ }
+
+ if (!QDBusConnection::sessionBus().registerService("org.mixxx")) {
+ fprintf(stderr, "%s\n", qPrintable(QDBusConnection::sessionBus().lastError().message()));
+ exit(1);
+ }
+
MixxxApp* mixxx = new MixxxApp(&a, args);
+ QDBusConnection::sessionBus().registerObject("/MixxxApp", mixxx, QDBusConnection::ExportScriptableSlots);
+ QDBusConnection::sessionBus().registerObject("/PlayerManager", mixxx->getPlayerManager(), QDBusConnection::ExportScriptableSlots);
+
//a.setMainWidget(mixxx);
QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
diff --git a/mixxx/src/mixxx.h b/mixxx/src/mixxx.h
index 5f410d7..c0d940e 100644
--- a/mixxx/src/mixxx.h
+++ b/mixxx/src/mixxx.h
@@ -68,6 +68,8 @@ class MixxxApp : public QMainWindow {
void setToolTips(int tt);
void rebootMixxxView();
+ PlayerManager* getPlayerManager() { return m_pPlayerManager; };
+
public slots:
//void slotQuitFullScreen();
diff --git a/mixxx/src/playermanager.cpp b/mixxx/src/playermanager.cpp
index ce6267b..64eedd1 100644
--- a/mixxx/src/playermanager.cpp
+++ b/mixxx/src/playermanager.cpp
@@ -368,4 +368,14 @@ void PlayerManager::slotLoadTrackIntoNextAvailableSampler(TrackPointer pTrack)
}
}
+bool PlayerManager::slotIsDeckPlaying(int deckNumber)
+{
+ QString group = groupForDeck(deckNumber-1);
+ ControlObject* play =
+ ControlObject::getControl(ConfigKey(group, "play"));
+ if (play && play->get() > 0.0) {
+ return true;
+ }
+ return false;
+}
diff --git a/mixxx/src/playermanager.h b/mixxx/src/playermanager.h
index fb70610..fac5709 100644
--- a/mixxx/src/playermanager.h
+++ b/mixxx/src/playermanager.h
@@ -91,7 +91,7 @@ class PlayerManager : public QObject {
// Slots for loading tracks to decks
void slotLoadTrackIntoNextAvailableDeck(TrackPointer pTrack);
// Loads the location to the deck. deckNumber is 1-indexed
- void slotLoadToDeck(QString location, int deckNumber);
+ Q_SCRIPTABLE void slotLoadToDeck(QString location, int deckNumber);
// Loads the location to the preview deck. previewDeckNumber is 1-indexed
void slotLoadToPreviewDeck(QString location, int previewDeckNumber);
@@ -104,6 +104,13 @@ class PlayerManager : public QObject {
void slotNumSamplersControlChanged(double v);
void slotNumPreviewDecksControlChanged(double v);
+ Q_SCRIPTABLE bool slotIsDeckPlaying(int deckNumber);
+
+ /* At the command line this call is possible then:
+ qdbus org.mixxx /PlayerManager org.mixxx.Mixxx.PlayerManager.slotLoadToDeck /path/to/filename.mp3 1
+ qdbus org.mixxx /PlayerManager org.mixxx.Mixxx.PlayerManager.slotIsDeckPlaying 1
+ */
+
signals:
void loadLocationToPlayer(QString location, QString group);
--
1.7.10.4
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Get Mixxx, the #1 Free MP3 DJ Mixing software Today
http://mixxx.org
Mixxx-devel mailing list
Mixxx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mixxx-devel