QMediaPlayer freezes when changing source a second time

36 views Asked by At

The first time I call setSource() everything goes smoothly. However if I try to call setSource() after media has started playing, even when calling stop() beforehand, the program freezes.

The specific lines of code are:

self.player.stop()
self.player.setSource(QUrl.fromLocalFile((self.playlist[self.track].fileName())))

Annoyingly it runs perfectly in debug mode, so not really sure what the error is.

I was expecting it to simply change the media and then become ready to play the next song.

1

There are 1 answers

0
Drew Walton On

I solved the freezing by: setting player.position to player.duration, and then waiting until it reaches EndOfMedia before loading the next source