Gapless audio playback



  • Does an example exist (preferably in Python) of how to use QMediaGaplessPlaybackControl? I have QMediaPlayer working to play a sound file, but now I would like to add the ability to segue from one sound file to another without a gap. The documentation is unusually opaque, even for Qt.





  • Thanks for pointing me to that thread, but it does not actually present a solution to the problem. I believe that the solution involves QMediaGaplessPlaybackControl, but I can't find any documentation explaining how to use that class. The documentation says, "If a QMediaService supports gapless playback it will implement QMediaGaplessPlaybackControl". Am I supposed to create a QMediaService or is there a QMediaService that already supports gapless playback? If I create a QMediaService, how do I make it subsume the functions of QMediaPlayer? What is a QMediaService? Maybe an example of creating a QMediaService -- even one that does not involve gapless playback -- would be helpful.



  • I found this source code in git. If I understand correctly that I am looking at the source code for Qt, then it appears that gapless playback has not been implemented. Do I have this assessment right?


  • Lifetime Qt Champion

    Hi,

    You are looking at the interface the backend needs to implement to provide gapless playback.

    One way to check is to request the corresponding control from your QMediaPlayer. If it's nullptr then the platform doesn't support it currently (depending on the platform there might be no support at all)



  • Thanks for the reply.

    player = QMediaPlayer()
    player.service().requestControl("org.qt-project.qt.mediagaplessplaybackcontrol/5.0")

    returns None, so I presume that my platform (Kubuntu 19.10) does not support gapless playback -- unless the command I used to request the control is not correct. It appears that I am running Qt 5.12.4.



  • The link I provided talked about using 2 players to do gapless playback. The concept would be the same for whatever player you are using.

    Maybe if you describe the context of how you are using this then people might be able to help better.



  • Some CDs have multiple tracks for a single movement of a symphonic work or a single act of an opera. When I rip the CD, I get multiple sound files corresponding to that one movement or act. The transition from one sound file to the next has to happen at exactly the right time without any crossfade. I could assemble the sound files into a single sound file, but then I lose the ability to jump directly to a particular section of the movement or a particular scene within an act.


  • Lifetime Qt Champion

    What OS are you on ?



  • Kubuntu 19.10.



  • Does anyone know whether it is possible to use GStreamer with Qt? Normally GStreamer uses GObject for the event loop. Is it possible to use GStreamer with the event loop in Qt instead? I am asking about GStreamer because it does support gapless audio playback.


  • Lifetime Qt Champion

    The Linux backend uses GStreamer. You can take a look at the code and maybe modify it for your purpose.


Log in to reply