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. Does "playbackRate" property in Audio component work at all?

Does "playbackRate" property in Audio component work at all?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 644 Views 1 Watching
  • 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
    Amir Afendin
    wrote on last edited by
    #1

    I use qt 5.12. When I try to set playbackRate property of Audio component, I dont' see any effect. I tried values from 0.1 to 2.0.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Works fine for me:
      Qt 5.12.9
      Linux

      You will need to provide your own sound. Mine is in a qrc file with "sound" prefix.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtMultimedia 5.12
      import QtQuick.Controls 2.12
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Audio Test")
      
          Button {
              id: button
      
              text: "play sound"
              onClicked: {
                  console.log(text)
                  audio.play()
              }
          }
          Slider {
              id: slider
      
              anchors.top: button.bottom
      
              from: 0.1
              to: 2.0
              value: 1.0
      
              width: 200
          }
      
          Audio {
              id: audio
      
              playbackRate: slider.value
      
              source: "sound/haha.ogg"
          }
      }
      

      C++ is a perfectly valid school of magic.

      A 1 Reply Last reply
      2
      • fcarneyF fcarney

        Works fine for me:
        Qt 5.12.9
        Linux

        You will need to provide your own sound. Mine is in a qrc file with "sound" prefix.

        import QtQuick 2.12
        import QtQuick.Window 2.12
        import QtMultimedia 5.12
        import QtQuick.Controls 2.12
        
        Window {
            visible: true
            width: 640
            height: 480
            title: qsTr("Audio Test")
        
            Button {
                id: button
        
                text: "play sound"
                onClicked: {
                    console.log(text)
                    audio.play()
                }
            }
            Slider {
                id: slider
        
                anchors.top: button.bottom
        
                from: 0.1
                to: 2.0
                value: 1.0
        
                width: 200
            }
        
            Audio {
                id: audio
        
                playbackRate: slider.value
        
                source: "sound/haha.ogg"
            }
        }
        
        A Offline
        A Offline
        Amir Afendin
        wrote on last edited by
        #3

        @fcarney
        What about mp3 sounds that are in playlist and loaded from arbitrary folder on the system and not from qrc file?

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          @Amir-Afendin said in Does "playbackRate" property in Audio component work at all?:

          mp3 sounds that are in playlist and loaded from arbitrary folder

          I put in a fixed url: file:///home/fcarney/Music/melting.mp3
          It played just fine. I could adjust the playback rate. However, for all sounds you cannot adjust rate while it is playing. It only seems to accept rate when it starts playing back.

          C++ is a perfectly valid school of magic.

          A 1 Reply Last reply
          0
          • fcarneyF fcarney

            @Amir-Afendin said in Does "playbackRate" property in Audio component work at all?:

            mp3 sounds that are in playlist and loaded from arbitrary folder

            I put in a fixed url: file:///home/fcarney/Music/melting.mp3
            It played just fine. I could adjust the playback rate. However, for all sounds you cannot adjust rate while it is playing. It only seems to accept rate when it starts playing back.

            A Offline
            A Offline
            Amir Afendin
            wrote on last edited by Amir Afendin
            #5

            @fcarney

            Audio {
                    source: "file:///home/amir/Downloads/beautiful.mp3"
                    playbackRate: 0.5
                    onStatusChanged: play()
                }
            

            Mine isn't working. I tried different values on playbackRate but it plays normal speed. Xubuntu18.04 / Qt 5.12.7

            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