当我尝试播放不在 qrc 中的媒体文件时出现错误 "Attempting to play invalid Qt resource"

I get an error "Attempting to play invalid Qt resource" when I try to play a mediafile which is not in the qrc

当然,如果我在 qrc 文件中包含特定的媒体文件,那么下面的 qml 程序似乎可以检测到它。

我想让用户通过文件浏览器select他想要的媒体文件,然后播放。

所以,目前,我以字符串形式传递文件路径如下:

import QtQuick 2.0
import QtMultimedia 5.5

Rectangle
{
    id:     head
    width:  500
    height: 500

    property int    heightOfButtons: 50
    property int    widthOfButtons: 50
    property string videoSource: "/home/*****/1.mp4"

    Video
    {
        id: video
        width : head.width
        height : head.height
        source: head.videoSource

        MouseArea
        {
            anchors.fill: parent
            onClicked: { video.play() }
        }

        onErrorStringChanged: console.log("errorstring: " + errorString)
        focus: true
    }

    Grid
    {
        columns: 1; columnSpacing: 10
        Rectangle
        {
            height: head.heightOfButtons; width: head.widthOfButtons; color: "green"
            id: playStop
            MouseArea {anchors.fill: parent; onClicked: video.playbackState == MediaPlayer.PlayingState ? video.pause() : video.play()}
            Text {color: "white"; text: "Play/Pause";  anchors.right: parent.right; anchors.horizontalCenter: parent.horizontalCenter}
        }

        Rectangle
        {
            height: rightGrid.heightOfButtons; width: rightGrid.widthOfButtons; color: "red"
            id: stop
            MouseArea {anchors.fill: parent; onClicked: video.stop()}
            Text {color: "white"; text: "Stop";  anchors.right: parent.right; anchors.horizontalCenter: parent.horizontalCenter;}
        }
    }
}

文件存在,但程序显示错误:

qml: errorstring: Attempting to play invalid Qt resource

如何动态播放用户select的文件?

解决方案是将媒体文件的路径指定为:

property string videoSource: "file:///home/***/1.mp4"

http://doc.qt.io/qt-5/qml-url.html