首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用QML视频在Mac OS X上播放断断续续的视频

使用QML视频在Mac OS X上播放断断续续的视频
EN

Stack Overflow用户
提问于 2011-06-07 16:38:31
回答 1查看 785关注 0票数 1

我正在尝试用QML创建简单的视频播放器。我已经安装了QtSdk,并从源代码编译和安装了QtMobility。然后我把这个简单的视频播放代码放到主qml文件中:

代码语言:javascript
复制
import QtQuick 1.0
import QtMultimediaKit 1.1

Item{
    width: 400; height: 300
    Video {
        id: video
        source: "d:/Projects/Serenity - HD DVD Trailer.mp4"
        anchors.fill: parent
        MouseArea {
            anchors.fill: parent
            onClicked: {
                video.play()
            }
        }
    }
}

在编译和运行应用程序后,视频播放断断续续,在退出应用程序时,它会将此记录到日志中:

代码语言:javascript
复制
2011-06-07 11:13:44.055 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x10225ea60 of class NSCFNumber autoreleased with no pool in place - just leaking
2011-06-07 11:13:45.007 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x10264f030 of class __NSCFDate autoreleased with no pool in place - just leaking
2011-06-07 11:13:45.007 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x11a409000 of class NSCFTimer autoreleased with no pool in place - just leaking
2011-06-07 11:13:45.008 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x11a43e550 of class NSCFArray autoreleased with no pool in place - just leaking
2011-06-07 11:13:45.008 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x11a462560 of class __NSFastEnumerationEnumerator autoreleased with no pool in place - just leaking

如果有什么方法可以让它流畅地播放并防止记忆呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-22 16:05:29

解决了。我已经用过OpenGL了。工程甚至比Windows非-GL版本更好。下面是一个代码:

代码语言:javascript
复制
QDeclarativeView mainwindow;
mainwindow.setSource(QUrl::fromLocalFile("./qml/app.qml"));
QGLFormat format = QGLFormat(QGL::DirectRendering); // you can play with other rendering formats like DoubleBuffer or SimpleBuffer
format.setSampleBuffers(false);
QGLWidget *glWidget = new QGLWidget(format);
glWidget->setAutoFillBackground(false);
mainwindow.setViewport(glWidget);

注意:当前的Windows1.1版本有一个错误,不允许在QtMobility的OpenGL渲染模式下播放视频。所以我对win使用了原生的Qt渲染。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6262642

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档