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
    	 color:"black"
    	 radius:20
     
    	 MediaPlayer {
    		 id: mediaPlayer
    		 objectName: "mediaPlayer"
    		 autoLoad: true
    		 volume: 1
    		 playlist: Playlist {
    			 id: playlist
    			 PlaylistItem { source: "/testVideo.mp4"; }
    		   }
    		 onPlaying: {                                  
    			console.log("[qmlvideo] duration " + duration) 
    		 }
    	 }
     
    	 VideoOutput {
    		 id:videoOutput
    		 source:mediaPlayer
    		 anchors.fill: parent
    	 }
    	 function stop() {
    		 mediaPlayer.stop();
    	 }
    	 function setVolume(volume) {
    		 mediaPlayer.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.