skullmunky
May 30th, 2009, 08:10 AM
Following up on the MLT code sample I posted below, I'm now trying to embed the MLT player into a Qt application. Mlt provides a player that uses SDL, and it appears that the way you're supposed to use it is by simply setting the window ID to make it use your Qt window instead of creating its own.
I can make this work fine, by getting the winId() from my QMainWindow. But I'd really like to have it embedded into another widget inside the window, not the whole window.
When I do that, though, I get this X error:
X Error: BadGC (invalid GC parameter) 13
Extension: 133 (Uknown extension)
Minor opcode: 19 (Unknown request)
Resource id: 0x380000b
here's my code, or at least the main.cpp :
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <iostream>
#include <Mlt.h>
int main(int argc, char *argv[])
{
Mlt::Profile *profile;
Mlt::Repository *repository;
Mlt::Consumer *consumer;
Mlt::Producer *producer;
int winid;
QApplication a(argc, argv);
MainWindow w;
QWidget *ViewWidget;
ViewWidget = w.findChild<QWidget *>("ViewWidget");
profile = new Mlt::Profile();
repository = Mlt::Factory::init();
if (repository)
{
consumer = new Mlt::Consumer(*profile,"sdl_preview");
producer = new Mlt::Producer(*profile,NULL,argv[1]);
consumer->connect(*producer);
w.show();
winid = ViewWidget->winId();
std::cout << "Window ID: " << winid << "\n";
consumer->set("window_id",winid);
consumer->start();
a.exec();
delete(consumer);
delete(producer);
Mlt::Factory::close();
}
else
{
std::cerr << "Unable to locate factory modules\n";
}
return 0;
}
I can make this work fine, by getting the winId() from my QMainWindow. But I'd really like to have it embedded into another widget inside the window, not the whole window.
When I do that, though, I get this X error:
X Error: BadGC (invalid GC parameter) 13
Extension: 133 (Uknown extension)
Minor opcode: 19 (Unknown request)
Resource id: 0x380000b
here's my code, or at least the main.cpp :
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <iostream>
#include <Mlt.h>
int main(int argc, char *argv[])
{
Mlt::Profile *profile;
Mlt::Repository *repository;
Mlt::Consumer *consumer;
Mlt::Producer *producer;
int winid;
QApplication a(argc, argv);
MainWindow w;
QWidget *ViewWidget;
ViewWidget = w.findChild<QWidget *>("ViewWidget");
profile = new Mlt::Profile();
repository = Mlt::Factory::init();
if (repository)
{
consumer = new Mlt::Consumer(*profile,"sdl_preview");
producer = new Mlt::Producer(*profile,NULL,argv[1]);
consumer->connect(*producer);
w.show();
winid = ViewWidget->winId();
std::cout << "Window ID: " << winid << "\n";
consumer->set("window_id",winid);
consumer->start();
a.exec();
delete(consumer);
delete(producer);
Mlt::Factory::close();
}
else
{
std::cerr << "Unable to locate factory modules\n";
}
return 0;
}