Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113211

Windows: QMediaPlayer stuttering with some wave files

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.5, 6.6
    • 6.4.3, 6.5.0, 6.5.1
    • Multimedia
    • None
    • Windows
    • 98d875475 (dev), ff263023f (6.5), a96ed9408 (6.6)

    Description

      Steps to reproduce:

      • Play attached wav file with multimedia\player example
      • Note it stuttering compared to .mp3

      Here is a simple example code which uses QMediaPlayer to play an audio file:

      import sys
      import time

      from PySide6.QtCore import QUrl, QCoreApplication
      from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput
      from PySide6.QtWidgets import QApplication

      app = QApplication(sys.argv)

      #create a QMediaPlayer instance
      player = QMediaPlayer()

      #set the URL of the audio file to play

      url = QUrl.fromLocalFile(r"E:\PyCharmProjects\papagayo_clean\Tutorial Files\lame.wav")
      url = QUrl.fromLocalFile(r"E:\PyCharmProjects\papagayo_clean\Tutorial Files\scared.wav")
      player.setSource(url)
      audio_output = QAudioOutput()
      player.setAudioOutput(audio_output)
      while not player.mediaStatus() in [QMediaPlayer.MediaStatus.LoadedMedia, QMediaPlayer.MediaStatus.BufferedMedia,
                                         QMediaPlayer.MediaStatus.BufferingMedia]:
          print(player.mediaStatus())
          QCoreApplication.processEvents()
          time.sleep(0.1)

      #play the audio file
      print(player.mediaStatus())
      print("Playing: {}".format(url.toString()))
      player.play()

      #connect to the stateChanged signal to exit the program when the audio has finished playing
      player.playbackStateChanged.connect(lambda state:
                                          QApplication.quit() if state != QMediaPlayer.PlaybackState.PlayingState else None)

      #start the application event loop
      sys.exit(app.exec())

      Attached are 2 files, for the same sound. 
      If you change the code so that the mp3 loads then it will play fine, but if you play the wav file then it will stutter.

      Attachments

        1. scared.wav
          137 kB
        2. scared2.mp3
          198 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              artemiy Artem Dyomin
              steveway Stefan Murawski
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes