Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Question about QPlayList

    Language Bindings
    python
    2
    4
    1114
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • understatementOfTheYear
      understatementOfTheYear last edited by A Former User

      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

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • understatementOfTheYear
          understatementOfTheYear last edited by

          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!

          1 Reply Last reply Reply Quote 0
          • understatementOfTheYear
            understatementOfTheYear last edited by

            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?

            1 Reply Last reply Reply Quote 0
            • First post
              Last post