Important: Please read the Qt Code of Conduct -

[PySide6] QMediaPlayer setLoops black screen between loops

  • Hi, I created a small python app to view mp4 in a QMediaPlayer, i wanted to add a loops option. So i set the QMediaPlayer to setLoops(-1) for infinite loops but between those loops there a 1sec black screen before the video is played again. Is it intended ? It happens even with really low duration media so it kill the feeling of loop that i need.

    I can show you the code but it is literaly the template showed in the documentation of QMediaPlayer. Let me know if you need any other details.

    Thanks in advance.

  • Lifetime Qt Champion


    You should add:

    • exact version of PySide6
    • OS used
    • means of installation of PySide6

  • Hi, thanks for your help, the exact version of PySide6 is, i'm on windows 10 and i installed Pyside6 using pip (pip install PySide6).

    Have a nice day.

  • Hi @SGaist, did you take some time to take a look at my problem ?

    I did try to investigate on my side, to establish a patern where this black screen of 1sec come from. So i setup signals from the QMediaPlayer Class to check what is happening when a new loop is starting. I used multiple video size media (50kb to 30mb) and conclude that the size does not matter. I had a 1second black screen on a small size video looping and none one a bigger size.

    With the mediaStatusChanged signal i see that for some videos the blackscreen happened because the media stay longer to the LoadedMedia state for no reason. I combined this signal with the positionChanged signal to check how many time it get called before the media change from LoadedMedia to BufferedMedia.
    Most of the time the positionChanged signal is called only once (no blackscreen then) but for some videos it get called up to 7 times.

    So TLDR, why some media get stuck in LoadedMedia state longer than it should, especialy really low size file that don't need a long time to render.

    TLDR2 setLoops(-1) seem to not be consistant and i see better concistency using the positionChanged signal like that to loop "manualy" a media.

        def positionChanged(self, position):
            if(position == self.mediaPlayer.duration()):


  • Lifetime Qt Champion

    Sorry no I did not have time and currently I do not have a Windows machine at hand.

    Note that it might be related to the Windows multimedia API used.

Log in to reply