我正在准备在嵌入式设备上播放视频的QML插件,其他开发人员可以不费吹灰之力地使用它。但是,目前提出的方法几乎总是需要围绕QML应用程序编写一些C++包装器。我指的是这个例子:8cpp-example.html
我希望能有一个插件,并简单地写:
import AwesomeVideoPlugin 1.0
Rect
{
AwesomeVideo
{
width: 320
height: 240
url: "./myvideo.avi"
// ... some minor stuff like mouse click handling, controls, etc.
}
}目前,QtGStreamer需要向VideoItem提供videoSurface属性。唯一的方法是在rootContext()中为附加属性创建和设置上下文。要创建GraphicsVideoSurface,我需要QGraphicsView (QDeclarativeView填充这个角色)。
是否可以:
格列茨
亚特萨
发布于 2012-08-08 15:25:30
我也有同样的问题,但还没有想出一个优雅的解决方案。
但是,一个想法是通过子类QApplication对象的访问器函数使视频界面可用。
当然,这意味着插件依赖于具有getVideoSurface方法的应用程序子类,但是它确实从QML代码中删除了丑陋。
class MyApp : public QApplication
{
....
QGst::Ui::GraphicsVideoSurface *getVideoSurface() { return m_videosurface; }
}
...
int MyApp::init()
{
m_viewer = new QDeclarativeView();
m_viewer->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
m_videosurface = new QGst::Ui::GraphicsVideoSurface(m_viewer);
}
MyVideoPlugin::MyVideoPlugin(QDeclarativeItem *parent) : QDeclarativeItem(parent)
{
QGst::Ui::GraphicsVideoSurface *surface = ((MyApp*)qApp)->getVideoSurface();
}
...现在,可以使用MyVideoPlugin元素而不引用导出的视频界面上下文项。
https://stackoverflow.com/questions/11845199
复制相似问题