Aamir
Aamir

Reputation: 11

Alot of packages errors while trying to build a simple video loading program

I was trying to make a qml based program that: • Loads a video file from File Picker dialog • Has play and pause buttons and a progress slider • Slider should also allow user to drag to seek playback position of the video file that’s being played.

But I am facing alot of errors like qrc:/vidprac3/main.qml:34:13: Cannot assign to non-existent property "maximumValue" and many more errors. i'm using qt version 6.2.

import QtQuick 2.0 import QtMultimedia 5.0 import QtQuick.Controls 2.15

Item { width: 640 height: 480

Video {
    id: video
    anchors.fill: parent
    source: ""
    // Add properties to track video state and position
    property bool playing: false
    property int position: 0
    // Connect to video's signals to keep state and position updated
    onPlayingChanged: playing = video.playing
    onPositionChanged: position = video.position
}

Row {
    anchors.bottom: parent.bottom
    anchors.horizontalCenter: parent.horizontalCenter

    Button {
        id: playButton
        text: video.playing ? "Pause" : "Play"
        onClicked: video.playing ? video.pause() : video.play()
    }

    Slider {
        id: progressSlider
        minimumValue: 0
        maximumValue: video.duration // Use video.duration as maximum value
        value: video.position
        onValueChanged: video.position = value
    }

}

// Add signal handlers to update UI when video state changes
Connections {
    target: video
    onPlayingChanged: playButton.text = video.playing ? "Pause" : "Play"
    onPositionChanged: progressSlider.value = video.position
}

Button {
    id: openButton
    text: "Open Video"
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.bottom: parent.bottom
    onClicked: {
        var fileDialog = Qt.createQmlObject('import QtQuick.Dialogs 1.3; FileDialog {}', parent)
        fileDialog.title = "Open Video"
        fileDialog.selectMultiple = false
        fileDialog.accepted.connect(function() {
            video.source = fileDialog.fileUrl
        })
        fileDialog.show()
    }
}

}

trying to run the app but it's constantly throwing errors.

Upvotes: 0

Views: 160

Answers (1)

Jürgen Lutz
Jürgen Lutz

Reputation: 806

You are using QtQuick.Controls 2.15. There the Slider control has no maximumValue property. It is renamed to the property "to":

Slider {
    from: 0
    to: video.duration
}

Upvotes: 1

Related Questions