Question about QPlayList
-
Hi,
After doing a bit of reading up on documentation for QMediaPlayer(there isn't much for Python, sadly), I realized that the only way to do a loop in QMediaPlayer is by passing it a QPlayList rather than using setMedia(QMediaContent).
All seemed to compile fine except now I'm not getting any video playback at all.
Here's my code:playlist = QMediaPlaylist() playlist.setPlaybackMode(3) # I think this is setting it to loop playlist.addMedia(QMediaContent(QUrl.fromLocalFile(video_path))) playlist.setCurrentIndex(0) self.preview_mPlayer.setPlaylist(playlist) # "self.preview_mPlayer" would be my QMediaPlayer object self.preview_mPlayer.play()
If I avoided all this and ran this instead:
self.preview_mPlayer.setMedia(QMediaContent(QUrl.fromLocalFile(video_path))) self.preview_mPlayer.play()
the video plays fine (albeit without looping)
Has anyone had any experience with QPlayList and have gotten it to work?
Thanks!
-Mark -
Hi,
Since you only have one element, I'd use CurrentItemInLoop.
You should also add error checking to get more information about what is going on.
-
I don't think QMediaContent has a way of setting the playback type like QPlayList does.
I did manage to get around the issue by signalling when playback state changed to zero to play the video over again. Currently that seems to work fine.Thanks!
-
Just an update to the working state of this code. Yes it does loop as it should in both mac and windows, however, when it loops on the mac, the video scales up for some bizarre reason. I have no clue what would make it do that. Any thoughts?