Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Question about QPlayList

Question about QPlayList

Scheduled Pinned Locked Moved Unsolved Language Bindings
python
4 Posts 2 Posters 1.5k Views
  • 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.
  • understatementOfTheYearU Offline
    understatementOfTheYearU Offline
    understatementOfTheYear
    wrote on last edited by A Former User
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      1
      • understatementOfTheYearU Offline
        understatementOfTheYearU Offline
        understatementOfTheYear
        wrote on last edited by
        #3

        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
        0
        • understatementOfTheYearU Offline
          understatementOfTheYearU Offline
          understatementOfTheYear
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved