Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MediaPlayer QML duration

MediaPlayer QML duration

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 654 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    apic
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved