Results 1 to 2 of 2

Thread: xbmc inside a Qt GUI

  1. #1
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default xbmc inside a Qt GUI

    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.

  2. #2
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: xbmc inside a Qt GUI

    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.

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QString>
    5. #include <QX11EmbedContainer>
    6. #include <QtGui>
    7. #include <QProcess>
    8.  
    9. namespace Ui
    10. {
    11. class MainWindow;
    12. }
    13. //////////////////////////////////////////
    14.  
    15. class MainWindow : public QWidget
    16. {
    17. Q_OBJECT
    18.  
    19. public:
    20. MainWindow(int embedDelay, QWidget *parent = 0);
    21. ~MainWindow();
    22.  
    23. private slots:
    24.  
    25. private:
    26. Ui::MainWindow *ui;
    27.  
    28. QProcess* m_XbmcProc;
    29.  
    30. QX11EmbedContainer *m_EmbedContainer;
    31.  
    32. int m_EmbedDelay;
    33.  
    34. void startAndEmbedXbmc();
    35. };
    36. //////////////////////////////////////////
    37. //////////////////////////////////////////
    38.  
    39. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. ///////////////////////////////////////////
    4. ///////////////////////////////////////////
    5.  
    6. MainWindow::MainWindow(int embedDelay, QWidget *parent) :
    7. QWidget (parent)
    8. , ui (new Ui::MainWindow)
    9. , m_EmbedDelay(embedDelay)
    10. {
    11. ui->setupUi(this);
    12.  
    13. m_EmbedContainer = new QX11EmbedContainer(this);
    14. m_EmbedContainer->setPalette(QPalette(Qt::darkGray));
    15. m_EmbedContainer->setAutoFillBackground(true);
    16.  
    17. QVBoxLayout *layout = new QVBoxLayout(ui->wdgVideo);
    18. layout->addWidget(m_EmbedContainer, 0);
    19.  
    20. startAndEmbedXbmc();
    21. }
    22. ///////////////////////////////////////////
    23.  
    24. MainWindow::~MainWindow()
    25. {
    26. m_XbmcProc->terminate();
    27. m_XbmcProc->waitForFinished();
    28.  
    29. // kill xbmc.bin
    30. QProcess proc;
    31. proc.start("killall xbmc.bin");
    32. proc.waitForFinished(-1);
    33.  
    34. delete ui;
    35. }
    36. ///////////////////////////////////////////
    37.  
    38. void MainWindow::startAndEmbedXbmc()
    39. {
    40. m_XbmcProc = new QProcess(this);
    41. m_XbmcProc->start("xbmc");
    42.  
    43. // ugly but needed otherwise the xbmc is not properly embedded (too fast)
    44. // with m_XbmcProc->waitForStarted() it doesn't work
    45. sleep(m_EmbedDelay);
    46.  
    47. // get the win id of the running xbmc
    48. QProcess getWinId;
    49. getWinId.start("sh", QStringList() << "-c" << "xwininfo -root -all | grep 'XBMC' | awk '{print $1}'");
    50. getWinId.waitForFinished();
    51. QString p_stdout = getWinId.readAllStandardOutput();
    52. getWinId.close();
    53. // embed the xbmc
    54. m_EmbedContainer->embedClient(p_stdout.toInt(NULL, 16));
    55. }
    56. ///////////////////////////////////////////
    57. ///////////////////////////////////////////
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 0
    Last Post: 16th July 2012, 09:56
  2. How to run with mpirun inside Qt?
    By mirzadeh in forum Newbie
    Replies: 6
    Last Post: 11th June 2011, 22:32
  3. QuaZip + dir inside
    By Axsis in forum Newbie
    Replies: 0
    Last Post: 7th May 2008, 12:28
  4. QT 4.2.3 Using GTK Widgets inside QT App
    By chuckshaw in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2007, 03:40
  5. how to use qApp inside a dll?
    By oob2 in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2006, 22:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.