QML:更改视频项的源会导致挂起

时间:2016-02-22 10:40:06

标签: qt video qml

我在更改视频项目来源方面遇到了麻烦。在下面的代码中,我通过鼠标单击从文件夹中随机选择一个mov文件。在2-7(最大)次之后,它总是挂起(在改变时)。所有的mov都相当小(700 kb - 7 mb),H.264,Mac OS。任何想法如何解决它?

import QtQuick 2.4
import QtMultimedia 5.4
import Qt.labs.folderlistmodel 2.1


Item {
    id:container
    property bool change_video: false
    width: 320
    height: 240

    FolderListModel {
           id: folderModel
           folder: "file:///Users/michaellevin/Dropbox/Movie/Xcanvas/XXX/animation/"
           nameFilters: ["*.mov"] }

    Video
    {   id: vvv
        width: container.width
        height: container.height
        //autoLoad: true
        autoPlay: true
        anchors.fill: parent
        anchors.margins: 0
        onStopped: play()
    }

    MouseArea {
        id: xxx
        anchors.fill: parent
        onClicked: {
            var index = Math.floor(Math.random()*(folderModel.count))
            print(index)
            //vvv.stop()
            vvv.source = folderModel.get(index, "fileURL")
            //vvv.play()
        }
    }

    Timer {
        id: start; interval: 10; running: true; repeat: false;
        onTriggered: vvv.source = folderModel.get(2, "fileURL")
    }
}

0 个答案:

没有答案