Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QtMediaplayer wont work on frameless and translucent background PyQt5
Qt 6.11 is out! See what's new in the release blog

QtMediaplayer wont work on frameless and translucent background PyQt5

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 1.8k Views 2 Watching
  • 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.
  • H Offline
    H Offline
    hacker6914
    wrote on last edited by
    #1

    I am making a videoplayer with QMediaplayer but it wont work on frameless and translucent background window.I want to make a round corner windows so i need frameless and translucent window. Here is my code:

    from PyQt5.QtCore import Qt, QUrl
    from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer
    from PyQt5.QtMultimediaWidgets import QVideoWidget
    from PyQt5.QtWidgets import QApplication,QMainWindow,QFrame
    import sys     
    class Player(QMainWindow):
        def __init__(self, parent=None):
            super().__init__(parent)
            self.setWindowTitle("PyQt Video Player Widget Example") 
            self.resize(600,400)
            self.frame=QFrame(self)
            self.frame.setStyleSheet('background:grey;border-radius:20px;')
            self.setCentralWidget(self.frame)
            #self.setWindowFlag(Qt.FramelessWindowHint)
            #self.setAttribute(Qt.WA_TranslucentBackground)
            self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)
            videoWidget = QVideoWidget(self.frame)
            videoWidget.setGeometry(10,10,580,380)
            self.resize(600,400)
            self.mediaPlayer.error.connect(self.handleError)
            self.mediaPlayer.setVideoOutput(videoWidget)
            self.mediaPlayer.setMedia(
                             QMediaContent(QUrl.fromLocalFile("C:/Users/mishra/Desktop/HiddenfilesWindow/10000000_1874628825927192_6229658593205944320_n(1).mp4")))
            self.mediaPlayer.play()
        def handleError(self):
            print("Error: " + self.mediaPlayer.errorString())
              
    if __name__ == "__main__":
        import sys
        app = QApplication(sys.argv)
        window = Player()
        
        window.show()
        sys.exit(app.exec_())
    

    After setting translucent background it only plays audio not video.Anybody knows how to fix it?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which OS are you on ?
      Which version of PyQt5 are you using ?

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

      H 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        Which OS are you on ?
        Which version of PyQt5 are you using ?

        H Offline
        H Offline
        hacker6914
        wrote on last edited by hacker6914
        #3

        @SGaist I have pyqt5 5.15.1 and OS windows 8.1 32bit
        I have posted the same in Stackoverflow and i got an working answer here but he is using resizeEvent and masking. So my question is is it a Bug for Translucent background ?

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Which OS are you on ?
          Which version of PyQt5 are you using ?

          H Offline
          H Offline
          hacker6914
          wrote on last edited by hacker6914
          #4
          This post is deleted!
          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