How to play a video using video 5.12 qt qml?

Viewed 647

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.

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()}
            }
        }
    }
}
1 Answers

the issue is the source. You need to use an URL format: source: "file:///home/user/videos/a.avi"

Alternatively, you can embed the video in the executable using the QtResources file (.qrc).

Related