简体   繁体   English

如何使用视频 5.12 qt qml 播放视频?

[英]How to play a video using video 5.12 qt qml?

I want to play a video with the button of play, pause, forward the video in 10 seconds, and back the video using qml, but I don't know how.我想用播放按钮播放视频,暂停,在10秒内转发视频,然后使用qml返回视频,但我不知道怎么做。

something like this:像这样的东西:

import QtQuick 2.12

import QtQuick.Window 2.12

import QtMultimedia 5.12

import QtQuick.Controls 2.0

import QtQuick.Layouts 1.12

Window {
    visible: true
    width: 840
    height: 680
    title: qsTr("Hello World")

    ColumnLayout{
        Video {
            id: video
            width : 600
            height : 600
            source: "a.avi"

        }
        RowLayout{
            Button {
                width: 80
                height: 80
                text: "play"
                onClicked: {video.play()}
            }
            Button {
                width: 80
                height: 80
                text: "pause"
                onClicked: {video.pause()}
            }
            Button {
                width: 80
                height: 80
                text: "foward"
                onClicked: {video.foward()}
            }
            Button {
                width: 80
                height: 80
                text: "back"
                onClicked: {video.back()}
            }
        }
    }
}

the issue is the source .问题是 来源 You need to use an URL format: source: "file:///home/user/videos/a.avi"您需要使用 URL 格式: source: "file:///home/user/videos/a.avi"

Alternatively, you can embed the video in the executable using the QtResources file ( .qrc ).或者,您可以使用 QtResources 文件 ( .qrc ) 将视频嵌入到可执行文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM