Ok, the xbmc's forum said it's impossible so, instead of using the xbmc as a library, I've embedded it into a gui.
It's anyway possible to use it via http so I don't need any C++ API.
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QString>
#include <QX11EmbedContainer>
#include <QtGui>
#include <QProcess>
namespace Ui
{
class MainWindow;
}
//////////////////////////////////////////
{
Q_OBJECT
public:
MainWindow
(int embedDelay,
QWidget *parent
= 0);
~MainWindow();
private slots:
private:
Ui::MainWindow *ui;
int m_EmbedDelay;
void startAndEmbedXbmc();
};
//////////////////////////////////////////
//////////////////////////////////////////
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QString>
#include <QX11EmbedContainer>
#include <QtGui>
#include <QProcess>
namespace Ui
{
class MainWindow;
}
//////////////////////////////////////////
class MainWindow : public QWidget
{
Q_OBJECT
public:
MainWindow(int embedDelay, QWidget *parent = 0);
~MainWindow();
private slots:
private:
Ui::MainWindow *ui;
QProcess* m_XbmcProc;
QX11EmbedContainer *m_EmbedContainer;
int m_EmbedDelay;
void startAndEmbedXbmc();
};
//////////////////////////////////////////
//////////////////////////////////////////
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
#include "mainwindow.h"
#include "ui_mainwindow.h"
///////////////////////////////////////////
///////////////////////////////////////////
MainWindow
::MainWindow(int embedDelay,
QWidget *parent
) : , ui (new Ui::MainWindow)
, m_EmbedDelay(embedDelay)
{
ui->setupUi(this);
m_EmbedContainer
->setPalette
(QPalette(Qt
::darkGray));
m_EmbedContainer->setAutoFillBackground(true);
layout->addWidget(m_EmbedContainer, 0);
startAndEmbedXbmc();
}
///////////////////////////////////////////
MainWindow::~MainWindow()
{
m_XbmcProc->terminate();
m_XbmcProc->waitForFinished();
// kill xbmc.bin
proc.start("killall xbmc.bin");
proc.waitForFinished(-1);
delete ui;
}
///////////////////////////////////////////
void MainWindow::startAndEmbedXbmc()
{
m_XbmcProc->start("xbmc");
// ugly but needed otherwise the xbmc is not properly embedded (too fast)
// with m_XbmcProc->waitForStarted() it doesn't work
sleep(m_EmbedDelay);
// get the win id of the running xbmc
getWinId.
start("sh",
QStringList() <<
"-c" <<
"xwininfo -root -all | grep 'XBMC' | awk '{print $1}'");
getWinId.waitForFinished();
QString p_stdout
= getWinId.
readAllStandardOutput();
getWinId.close();
// embed the xbmc
m_EmbedContainer->embedClient(p_stdout.toInt(NULL, 16));
}
///////////////////////////////////////////
///////////////////////////////////////////
#include "mainwindow.h"
#include "ui_mainwindow.h"
///////////////////////////////////////////
///////////////////////////////////////////
MainWindow::MainWindow(int embedDelay, QWidget *parent) :
QWidget (parent)
, ui (new Ui::MainWindow)
, m_EmbedDelay(embedDelay)
{
ui->setupUi(this);
m_EmbedContainer = new QX11EmbedContainer(this);
m_EmbedContainer->setPalette(QPalette(Qt::darkGray));
m_EmbedContainer->setAutoFillBackground(true);
QVBoxLayout *layout = new QVBoxLayout(ui->wdgVideo);
layout->addWidget(m_EmbedContainer, 0);
startAndEmbedXbmc();
}
///////////////////////////////////////////
MainWindow::~MainWindow()
{
m_XbmcProc->terminate();
m_XbmcProc->waitForFinished();
// kill xbmc.bin
QProcess proc;
proc.start("killall xbmc.bin");
proc.waitForFinished(-1);
delete ui;
}
///////////////////////////////////////////
void MainWindow::startAndEmbedXbmc()
{
m_XbmcProc = new QProcess(this);
m_XbmcProc->start("xbmc");
// ugly but needed otherwise the xbmc is not properly embedded (too fast)
// with m_XbmcProc->waitForStarted() it doesn't work
sleep(m_EmbedDelay);
// get the win id of the running xbmc
QProcess getWinId;
getWinId.start("sh", QStringList() << "-c" << "xwininfo -root -all | grep 'XBMC' | awk '{print $1}'");
getWinId.waitForFinished();
QString p_stdout = getWinId.readAllStandardOutput();
getWinId.close();
// embed the xbmc
m_EmbedContainer->embedClient(p_stdout.toInt(NULL, 16));
}
///////////////////////////////////////////
///////////////////////////////////////////
To copy to clipboard, switch view to plain text mode
Bookmarks