MediaPlayer QML duration

  • Hello, i have following qml:

    import QtQuick 2.1
    import QtMultimedia 5.7
     Rectangle {
    	 x: 0
    	 y: 0
    	 width: 1152
    	 height: 675
    	 MediaPlayer {
    		 id: mediaPlayer
    		 objectName: "mediaPlayer"
    		 autoLoad: true
    		 volume: 1
    		 playlist: Playlist {
    			 id: playlist
    			 PlaylistItem { source: "/testVideo.mp4"; }
    		 onPlaying: {                                  
    			console.log("[qmlvideo] duration " + duration) 
    	 VideoOutput {
    		 anchors.fill: parent
    	 function stop() {
    	 function setVolume(volume) {

    this is used in a widgets application through QQuickWidget.
    When i call MediaPlayer::play() video plays correctly
    and onPlay is fired the problem is that duration property always return -1.
    Tryed also to connect playbackStateChanged() signal and also here duration is always -1
    both on start and stop.

    How can i get video duration?

    Thank you

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.