Qt Forum

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

    Solved Video Widget load Video

    General and Desktop
    3
    14
    319
    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.
    • O
      Osama_Billah last edited by Osama_Billah

      Hi, everyone I was loading Video in my QVideoWidget but it didn't load the Video.

          def load_video(self):
              filepath = 'F:/Fun/Songs/12.mp4'
              self.Video_Widget.load(filepath)
              # self.horizontalScrollBar.setMediaObject(self.Video_Widget.mediaObject())
              self.Video_Widget.play()
      

      I take help from this

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

        Hi,

        QVideoWidget has no such method.

        You have a use example in its detailed documentation.

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

        O 2 Replies Last reply Reply Quote 1
        • A
          anil_arise @Osama_Billah last edited by

          @Osama_Billah can you show your error message.

          another example : VideoPlayer

          1 Reply Last reply Reply Quote 1
          • O
            Osama_Billah @SGaist last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • O
              Osama_Billah @SGaist last edited by

              @SGaist While Using the Detail Documentation the following error occur.
              code is below

                  def load_video(self):
                      player = QMediaPlayer()
                      playlist = QMediaPlaylist(player)
                      playlist.addMedia(QUrl('F:/Fun/Songs/12.mp4'))
                      player.setVideoOutput(self.Video_Widget)
                      self.Video_Widget.show()
                      playlist.setCurrentIndex(1)
                      player.play()
              

              Capture.PNG

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

                Are you using PyQt or PySide2 ?

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

                O 2 Replies Last reply Reply Quote 0
                • O
                  Osama_Billah @SGaist last edited by

                  @SGaist PyQt5

                  1 Reply Last reply Reply Quote 0
                  • O
                    Osama_Billah @SGaist last edited by

                    @SGaist any suggestions. still stuck

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

                      Please show some patience and allow 24 hours before bumping your own thread. People answering here are volunteers and may not live in the same timezone as you.

                      As for your issue:

                      playlist.addMedia(QMediaContent(QUrl.fromLocalFile('F:/Fun/Songs/12.mp4')))
                      

                      [edit: use fromLocalFile SGaist]

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

                      O 1 Reply Last reply Reply Quote 1
                      • A
                        anil_arise @Osama_Billah last edited by

                        @Osama_Billah

                        use this
                        playlist.addMedia(QUrl.fromLocalFile("F:/Fun/Songs/12.mp4")) ******
                        instead of this
                        playlist.addMedia(QUrl('F:/Fun/Songs/12.mp4'))

                        ****** check file name in single quotes also

                        SGaist O 2 Replies Last reply Reply Quote 0
                        • SGaist
                          SGaist Lifetime Qt Champion @anil_arise last edited by

                          @anil_arise The current issue is completely unrelated to quoting or QUrl creation although the use of fromLocalFile is indeed a good idea. addMedia in C++ takes a QMediaContent object which is created thanks to implicit conversion from QUrl. Implicit conversion that does not happen here.

                          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 0
                          • O
                            Osama_Billah @SGaist last edited by

                            @SGaist Hi,I tried this method. through this method file don't crush but still don't display the video.

                            1 Reply Last reply Reply Quote 0
                            • O
                              Osama_Billah @anil_arise last edited by

                              @anil_arise first I use this method it crush. it show an error and the error is below. than I tried @SGaist given method. from that method it didn't crush but still don't disply the video
                              Capture.PNG

                              1 Reply Last reply Reply Quote 0
                              • O
                                Osama_Billah last edited by

                                @SGaist @anil_arise thanks. problem Solved. complete code is below

                                from PyQt5 import QtCore, QtGui, QtWidgets
                                
                                
                                class Ui_VideoWindow(object):
                                    def setupUi(self, MainWindow):
                                        MainWindow.setObjectName("MainWindow")
                                        MainWindow.resize(733, 505)
                                        self.centralwidget = QtWidgets.QWidget(MainWindow)
                                        self.centralwidget.setObjectName("centralwidget")
                                        self.Video_Widget = QVideoWidget(self.centralwidget)
                                        self.Video_Widget.setGeometry(QtCore.QRect(0, 0, 711, 361))
                                        self.Video_Widget.setObjectName("Video_Widget")
                                        self.horizontalScrollBar = QtWidgets.QScrollBar(self.centralwidget)
                                        self.horizontalScrollBar.setGeometry(QtCore.QRect(0, 380, 721, 16))
                                        self.horizontalScrollBar.setOrientation(QtCore.Qt.Horizontal)
                                        self.horizontalScrollBar.setObjectName("horizontalScrollBar")
                                        self.play = QtWidgets.QPushButton(self.centralwidget)
                                        self.play.setGeometry(QtCore.QRect(10, 410, 75, 23))
                                        self.play.setObjectName("play")
                                        MainWindow.setCentralWidget(self.centralwidget)
                                
                                        self.retranslateUi(MainWindow)
                                        QtCore.QMetaObject.connectSlotsByName(MainWindow)
                                
                                    def retranslateUi(self, MainWindow):
                                        _translate = QtCore.QCoreApplication.translate
                                        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
                                        self.play.setText(_translate("MainWindow", "play"))
                                
                                
                                from PyQt5.QtMultimediaWidgets import QVideoWidget
                                from PyQt5 import QtMultimedia
                                
                                
                                class VideoWindow(QtWidgets.QMainWindow, Ui_VideoWindow):
                                    def __init__(self, parent=None):
                                        super(VideoWindow, self).__init__(parent)
                                        self.setupUi(self)
                                        self.player = QtMultimedia.QMediaPlayer(self)
                                        self.player.setVideoOutput(self.Video_Widget)
                                        self.play.clicked.connect(self.player.play)
                                        self.playlist = QtMultimedia.QMediaPlaylist(self.player)
                                        self.player.setPlaylist(self.playlist)
                                        self.playlist.addMedia(
                                            QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile("F:/Fun/Songs/12.mp4"))
                                        )
                                        self.playlist.setCurrentIndex(0)
                                
                                
                                if __name__ == "__main__":
                                    import sys
                                
                                    app = QtWidgets.QApplication(sys.argv)
                                    w = VideoWindow()
                                    w.show()
                                    sys.exit(app.exec_())
                                
                                1 Reply Last reply Reply Quote 2
                                • First post
                                  Last post