trallallero
27th August 2012, 12:18
I'd like to use a xbmc video player inside a Qt GUI.
Is there someone that has done something like this ?
I've asked also in the xbmc's forum so, if I get some news, I'll update the thread.
trallallero
28th August 2012, 14:15
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;
}
//////////////////////////////////////////
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
#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));
}
///////////////////////////////////////////
///////////////////////////////////////////
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.