qt - 为什么 QML MediaPlayer/VideoOutput 对我不起作用?

我正在尝试通过以下代码使用 qml 播放测试视频:

import QtQuick 2.2
import QtMultimedia 5.0

Item {
    width: 300
    height: 300

    MediaPlayer {
        id: player
        source: "C:\\Downloads\\video.mp4"
    }

    VideoOutput {
        id: video
        anchors.fill: parent
        source: player
    }

    MouseArea {
        anchors.fill: parent
        onPressed: player.play()
    }
}

但是,当我点击 View 时,没有任何反应。如果我将 onPressed 事件更改为其他操作(不是 player),它工作正常,那么它不是 MouseArea 问题。

我哪里做错了?

谢谢。

最佳答案

文件路径好像有误。由于baclslashes需要在string literals中进行转义,所以剩下的实际路径是:

c:\Downloads\video.mp4

那是一个路径,而不是一个 URL。正确的 URL 是(参见 File URIs in Windows ):

file:///C:/Downloads/video.mp4

https://stackoverflow.com/questions/23208946/

相关文章:

angularjs - Uncaught Error : [$injector:modulerr]

clojure - 莱因环 uberjar

grep - 管道 shasum 到 grep,但 grep 返回管道输入的所有行,即使是不匹配的

mips - mips 中的算术溢出

sql - MSSQL : Display Rows for a Select with Case

process - 用于并行计算的 CPU 卡?

amazon-web-services - boto如何选择aws区域来创建buckets?

d3.js - 如何使用 dc.js 显示行图表的底部数据

coq - 形式化时间和空间复杂性要求

cordova - 在 Windows Phone 8 中调用日期时间选择器插件