Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Video Widget load Video
Forum Updated to NodeBB v4.3 + New Features

Video Widget load Video

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 1.1k 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.
  • O 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 Offline
    A Offline
    anil_arise
    wrote on last edited by
    #3

    @Osama_Billah can you show your error message.

    another example : VideoPlayer

    1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      QVideoWidget has no such method.

      You have a use example in its detailed documentation.

      O Offline
      O Offline
      Osama_Billah
      wrote on last edited by
      #4
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        QVideoWidget has no such method.

        You have a use example in its detailed documentation.

        O Offline
        O Offline
        Osama_Billah
        wrote on last edited by
        #5

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

          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
          0
          • SGaistS SGaist

            Are you using PyQt or PySide2 ?

            O Offline
            O Offline
            Osama_Billah
            wrote on last edited by
            #7

            @SGaist PyQt5

            1 Reply Last reply
            0
            • SGaistS SGaist

              Are you using PyQt or PySide2 ?

              O Offline
              O Offline
              Osama_Billah
              wrote on last edited by
              #8

              @SGaist any suggestions. still stuck

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

                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
                1
                • O Osama_Billah

                  @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 Offline
                  A Offline
                  anil_arise
                  wrote on last edited by
                  #10

                  @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

                  SGaistS O 2 Replies Last reply
                  0
                  • A anil_arise

                    @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

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @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
                    0
                    • SGaistS 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]

                      O Offline
                      O Offline
                      Osama_Billah
                      wrote on last edited by
                      #12

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

                      1 Reply Last reply
                      0
                      • A anil_arise

                        @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

                        O Offline
                        O Offline
                        Osama_Billah
                        wrote on last edited by
                        #13

                        @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
                        0
                        • O Offline
                          O Offline
                          Osama_Billah
                          wrote on last edited by
                          #14

                          @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
                          2

                          • Login

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