示例#1
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__()

        # window settings
        self.setWindowTitle("QRScanner App")

        # main layout
        self.lay = QtWidgets.QVBoxLayout()

        # widgets
        self.capture_button = QtWidgets.QPushButton("Capture")
        self.capture_button.clicked.connect(self.btn_click)
        self.label = QtWidgets.QLabel("")

        # setting the device
        self.device = QtMultimedia.QCamera.availableDevices()[0]
        self.m_camera = QtMultimedia.QCamera(self.device)

        #test
        self.label.setText(str(self.m_camera.availableDevices()))

        self.view_finder = QtMultimediaWidgets.QCameraViewfinder()
        self.view_finder.setMinimumSize(250, 250)

        self.m_camera.setViewfinder(self.view_finder)
        self.m_camera.setCaptureMode(QtMultimedia.QCamera.CaptureStillImage)
        self.m_camera.start()

        self.lay.addWidget(self.label)
        self.lay.addWidget(self.view_finder)
        self.lay.addWidget(self.capture_button)
        self.lay.addWidget(self.label)
        self.setLayout(self.lay)
示例#2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setupUi(self)

        video_widget = QtMultimediaWidgets.QVideoWidget()
        # video_widget.setStyle(self.video_widget.style())
        video_widget.setStyleSheet(self.video_widget.styleSheet())
        self.video_widget.parent().layout().replaceWidget(
            self.video_widget, video_widget)
        self.video_widget.deleteLater()
        self.video_widget = video_widget

        self.video_player = QtMultimedia.QMediaPlayer(
            None, QtMultimedia.QMediaPlayer.VideoSurface)
        self.video_player.setVolume(0)
        self.video_player.setNotifyInterval(100)
        self.video_player.error.connect(self.error)
        self.video_player.stateChanged.connect(self.media_state_changed)

        self.video_player.setVideoOutput(self.video_widget)

        self.play_button.clicked.connect(self.play)

        self.video_slider.setTickInterval(1)
        self.video_slider.sliderMoved.connect(self.video_player.setPosition)
        self.video_player.durationChanged.connect(self.video_slider.setMaximum)
        self.video_player.positionChanged.connect(self.video_slider.setValue)
示例#3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        layout = QtWidgets.QVBoxLayout(self)

        self.video_player = QtMultimedia.QMediaPlayer(
            None, QtMultimedia.QMediaPlayer.VideoSurface)
        self.video_player.error.connect(self.error)
        self.video_player.stateChanged.connect(self.media_state_changed)

        video_widget = QtMultimediaWidgets.QVideoWidget()
        self.video_player.setVideoOutput(video_widget)
        layout.addWidget(video_widget)

        control_layout = QtWidgets.QHBoxLayout()

        self.play_button = QtWidgets.QPushButton()
        self.play_button.setText("Play")
        self.play_button.clicked.connect(self.play)
        control_layout.addWidget(self.play_button)

        self.video_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
        self.video_slider.setMinimum(0)
        self.video_slider.sliderMoved.connect(self.video_player.setPosition)
        self.video_player.durationChanged.connect(self.video_slider.setMaximum)
        self.video_player.positionChanged.connect(self.video_slider.setValue)
        control_layout.addWidget(self.video_slider)

        layout.addLayout(control_layout)
示例#4
0
    def initGUI(self):

        self.videoWidget = QtMultimediaWidgets.QVideoWidget()
        self.setCentralWidget(self.videoWidget)



        self.mediaPlayer = QtMultimedia.QMediaPlayer(None, QtMultimedia.QMediaPlayer.VideoSurface)
        self.mediaPlayer.setVideoOutput(self.videoWidget)



        local = QtCore.QUrl.fromLocalFile('C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/vidbackground2.mov')
        media = QtMultimedia.QMediaContent(local)
        self.mediaPlayer.setMedia(media)

        print('state: ' + str(self.mediaPlayer.state()))
        print('mediaStatus: ' + str(self.mediaPlayer.mediaStatus()))
        print('error: ' + str(self.mediaPlayer.error()))

        self.mediaPlayer.play()

        print('state: ' + str(self.mediaPlayer.state()))
        print('mediaStatus: ' + str(self.mediaPlayer.mediaStatus()))
        print('error: ' + str(self.mediaPlayer.error()))
示例#5
0
    def __init__(self, *args, camera_info=None):
        super(CameraInterface, self).__init__(*args)
        # 定义相机实例对象并设置捕获模式
        if camera_info:
            self.mCamera = QCamera(camera_info)
        else:
            self.mCamera = QCamera()
        self.mCamera.setCaptureMode(QCamera.CaptureViewfinder)
        self.mDisplayWidth = 800
        self.mDisplayHeight = 600
        self.mRate = 10

        # 设置取景器分辨率
        self.setDisplaySize(self.mDisplayWidth, self.mDisplayHeight)

        self.setRate(self.mRate)

        # 初始化取景器
        self.mViewCamera = QtMultimediaWidgets.QCameraViewfinder(self)
        self.mViewCamera.show()
        self.mCamera.setViewfinder(self.mViewCamera)
        self.mCamera.setCaptureMode(QCamera.CaptureStillImage)

        # 设置图像捕获
        self.mCapture = QCameraImageCapture(self.mCamera)
        if self.mCapture.isCaptureDestinationSupported(
                QCameraImageCapture.CaptureToBuffer):
            self.mCapture.setCaptureDestination(
                QCameraImageCapture.CaptureToBuffer)  # CaptureToBuffer

        # self.mCapture.error.connect(lambda i, e, s: self.alert(s))
        self.mCapture.imageAvailable.connect(self.readFrame)

        self.mTimerImageGrab = QTimer(self)
        self.mTimerImageGrab.timeout.connect(self.timerImgGrab)
示例#6
0
    def __init__(self):
        super().__init__()
        self.setLayout(qtw.QVBoxLayout())

        # camera
        self.camera = qtmm.QCamera()

        # viewfinder
        cvf = qtmmw.QCameraViewfinder()
        self.camera.setViewfinder(cvf)
        self.layout().addWidget(cvf)

        # Form
        form = qtw.QFormLayout()
        self.layout().addLayout(form)

        # zoom
        zoomslider = qtw.QSlider(minimum=1,
                                 maximum=10,
                                 sliderMoved=self.on_slider_moved,
                                 orientation=qtc.Qt.Horizontal)
        form.addRow('Zoom', zoomslider)

        self.camera.start()
        self.show()
示例#7
0
    def __init__(self,
                 name,
                 default_position='float',
                 parent=None,
                 folded=False):
        """
        All of the panel constructors follow the same format so that the construction can be automated.
        :param name: Title of the panel and the key for accessing it
        :param default_position: 'bottom', 'right'...
        :param parent: self.main
        """

        Panel.__init__(self, name, default_position, parent, folded)
        self.camera = None
        self.aspect = 1.333333333
        self.camera_width = 320
        layout = QtWidgets.QVBoxLayout()
        widget = QtWidgets.QWidget()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
        self.viewfinder = QtMultimediaWidgets.QCameraViewfinder()
        layout.addWidget(self.viewfinder)
        widget.setLayout(layout)
        self.activate_camera()
        self.setWidget(widget)
        self.finish_init()
        self.releaseMouse()
示例#8
0
 def __init__(self):
     super(CameraMainWin, self).__init__()
     self.setupUi(self)
     #定义相机实例对象并设置捕获模式
     self.camera = QCamera()
     self.camera.setCaptureMode(QCamera.CaptureViewfinder)
     self.cameraOpened = False  # 设置相机打开状态为未打开
     #设置取景器分辨率
     viewFinderSettings = QCameraViewfinderSettings()
     viewFinderSettings.setResolution(800, 600)
     self.camera.setViewfinderSettings(viewFinderSettings)
     #初始化取景器
     self.viewCamera = QtMultimediaWidgets.QCameraViewfinder(self)
     self.camera.setViewfinder(self.viewCamera)
     self.camera.setCaptureMode(QCamera.CaptureStillImage)
     self.camerLayout.addWidget(self.viewCamera)  #取景器放置到预留的布局中
     #设置图像捕获
     self.capture = QCameraImageCapture(self.camera)
     self.capture.setCaptureDestination(
         QCameraImageCapture.CaptureToBuffer)  #CaptureToBuffer
     self.switchCamera: QPushButton
     self.switchCamera.clicked.connect(self.SwitchCamera)
     self.takePic.clicked.connect(self.TakePic)
     self.capture.error.connect(lambda i, e, s: self.alert(s))
     self.capture.imageAvailable.connect(self.saveImage)
     self.capture.imageCaptured.connect(
         lambda d, i: self.status.showMessage("Image %04d captured" % self.
                                              save_seq))
示例#9
0
文件: main.py 项目: ithuanhuan/Demo
    def __init__(self):
        QtWidgets.QWidget.__init__(self)
        # media
        self.media = Phonon.MediaObject(self)

        self.media.stateChanged.connect(self.handleStateChanged)
        self.video = Phonon.VideoWidget(self)
        self.video.setMinimumSize(200, 200)
        self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self)
        Phonon.createPath(self.media, self.audio)
        Phonon.createPath(self.media, self.video)

        # control button
        self.button = QtGui.QPushButton('选择文件', self)
        self.button.clicked.connect(self.handleButton)

        # for display of time lapse
        self.info = QtGui.QLabel(self)

        # layout
        layout = QtGui.QGridLayout(self)
        layout.addWidget(self.video, 1, 1, 3, 3)
        layout.addWidget(self.info, 4, 1, 1, 3)
        layout.addWidget(self.button, 5, 1, 1, 3)

        # signal-slot, for time lapse
        self.thread = PollTimeThread(self)
        self.thread.update.connect(self.update)
示例#10
0
文件: main.py 项目: ithuanhuan/Demo
    def startPlay(self):
        if self.path:
            self.media.setCurrentSource(Phonon.MediaSource(self.path))

            # use a thread as a timer
            self.thread = PollTimeThread(self)
            self.thread.update.connect(self.update)
            self.thread.start()
            self.media.play()
示例#11
0
    def __init__(self, file_head):
        super(Jeopardy_Wall, self).__init__()
        self.grid = QtWidgets.QGridLayout(self)

        self.file_head = file_head

        jeopardy_wall_layout = QtWidgets.QHBoxLayout(None)

        self.wall_button = []
        self.wall_category_boxes = []
        self.wall_category_layouts = []

        for i in range(5):
            self.wall_button.append([])
            self.wall_category_layouts.append(QtWidgets.QVBoxLayout(None))
            self.wall_category_boxes.append(QtWidgets.QGroupBox(""))
            self.wall_category_boxes[i].setLayout(
                self.wall_category_layouts[i])
            jeopardy_wall_layout.addWidget(self.wall_category_boxes[i])
            for j in range(5):
                self.wall_button[i].append(
                    QtWidgets.QPushButton(str((j + 1) * points_factor)))
                self.wall_button[i][j].setSizePolicy(
                    QtWidgets.QSizePolicy.Ignored,
                    QtWidgets.QSizePolicy.Ignored)
                self.wall_category_layouts[i].addWidget(self.wall_button[i][j])

        self.player_wall_layout = QtWidgets.QHBoxLayout(None)

        self.jeopardy_wall_box = QtWidgets.QGroupBox("Jeopardy board")
        wall_font = self.jeopardy_wall_box.font()
        wall_font.setPointSize(font_size_wall)
        self.jeopardy_wall_box.setFont(wall_font)
        self.jeopardy_wall_box.setLayout(jeopardy_wall_layout)

        player_wall_box = QtWidgets.QGroupBox("Player")
        player_wall_box.setLayout(self.player_wall_layout)

        answer_layout = QtWidgets.QVBoxLayout(None)
        self.answer_label = QtWidgets.QLabel("")
        self.answer_label.setHidden(True)
        answer_font = self.font()
        answer_font.setPointSize(font_size_answer)
        self.answer_label.setFont(answer_font)
        self.video_player = QtMultimedia.QMediaPlayer()
        self.video_widget = QtMultimediaWidgets.QVideoWidget()
        self.video_player.setVideoOutput(self.video_widget)
        self.video_widget.setHidden(True)
        answer_layout.addWidget(self.answer_label)
        answer_layout.addWidget(self.video_widget)
        self.answer_box = QtWidgets.QGroupBox("Answer")
        self.answer_box.setLayout(answer_layout)
        self.answer_box.setHidden(True)

        self.grid.addWidget(self.answer_box, 0, 0, 8, 0)
        self.grid.addWidget(self.jeopardy_wall_box, 0, 0, 8, 0)
        self.grid.addWidget(player_wall_box, 9, 0)
示例#12
0
 def __init__(self, parent=None):
     QtWidgets.QWidget.__init__(self,
                                parent,
                                flags=QtCore.Qt.Window
                                | QtCore.Qt.MSWindowsFixedSizeDialogHint)
     self.setWindowTitle("Видеопроигрыватель")
     self.mplPlayer = QtMultimedia.QMediaPlayer()
     self.mplPlayer.setVolume(50)
     self.mplPlayer.mediaStatusChanged.connect(self.initPlayer)
     self.mplPlayer.stateChanged.connect(self.setPlayerState)
     vbox = QtWidgets.QVBoxLayout()
     btnOpen = QtWidgets.QPushButton("&Открыть файл...")
     btnOpen.clicked.connect(self.openFile)
     vbox.addWidget(btnOpen)
     vwg = QtMultimediaWidgets.QVideoWidget()
     vwg.setAspectRatioMode(QtCore.Qt.KeepAspectRatio)
     self.mplPlayer.setVideoOutput(vwg)
     vbox.addWidget(vwg)
     self.sldPosition = QtWidgets.QSlider(QtCore.Qt.Horizontal)
     self.sldPosition.setMinimum(0)
     self.sldPosition.valueChanged.connect(self.mplPlayer.setPosition)
     self.mplPlayer.positionChanged.connect(self.sldPosition.setValue)
     self.sldPosition.setEnabled(False)
     vbox.addWidget(self.sldPosition)
     hbox = QtWidgets.QHBoxLayout()
     self.btnPlay = QtWidgets.QPushButton("&Пуск")
     self.btnPlay.clicked.connect(self.mplPlayer.play)
     self.btnPlay.setEnabled(False)
     hbox.addWidget(self.btnPlay)
     self.btnPause = QtWidgets.QPushButton("П&ауза")
     self.btnPause.clicked.connect(self.mplPlayer.pause)
     self.btnPause.setEnabled(False)
     hbox.addWidget(self.btnPause)
     self.btnStop = QtWidgets.QPushButton("&Стоп")
     self.btnStop.clicked.connect(self.mplPlayer.stop)
     self.btnStop.setEnabled(False)
     hbox.addWidget(self.btnStop)
     vbox.addLayout(hbox)
     hbox = QtWidgets.QHBoxLayout()
     lblVolume = QtWidgets.QLabel("&Громкость")
     hbox.addWidget(lblVolume)
     sldVolume = QtWidgets.QSlider(QtCore.Qt.Horizontal)
     sldVolume.setRange(0, 100)
     sldVolume.setTickPosition(QtWidgets.QSlider.TicksAbove)
     sldVolume.setTickInterval(10)
     sldVolume.setValue(50)
     lblVolume.setBuddy(sldVolume)
     sldVolume.valueChanged.connect(self.mplPlayer.setVolume)
     hbox.addWidget(sldVolume)
     btnMute = QtWidgets.QPushButton("&Тихо!")
     btnMute.setCheckable(True)
     btnMute.toggled.connect(self.mplPlayer.setMuted)
     hbox.addWidget(btnMute)
     vbox.addLayout(hbox)
     self.setLayout(vbox)
     self.resize(600, 600)
示例#13
0
    def startMedia(self):
        if self.fileType in {"mp4"}:
            if not hasattr(
                    self, "player"
            ):  #Если медиаплеер существует то больше его не создавать
                self.player = QtMultimedia.QMediaPlayer()

            if not hasattr(
                    self, "viewer"
            ):  #Если проигрыватель существует не создавать больше его
                self.viewer = QtMultimediaWidgets.QVideoWidget()
                self.viewer.resize(700, 600)
                self.viewer.move(0, 0)

                self.player.setVideoOutput(self.viewer)
            self.player.setMedia(
                QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(
                    self.path)))
            self.hbox = QtWidgets.QHBoxLayout(self.mediaQt.videoMediaWidget)

            self.hbox.addWidget(self.viewer)
            self.player.setPosition(0)

            self.viewer.show()
        elif self.fileType in {"png", "jpg", "JPG"}:
            pix = QtGui.QPixmap()
            pix.load(self.path)

            if MediaQt.open:
                self.hbox = QtWidgets.QHBoxLayout(
                    self.mediaQt.photoMediaWidget)
                self.lbl = QtWidgets.QLabel(self.mediaQt.photoMediaWidget)
                self.lbl.setAlignment(QtCore.Qt.AlignCenter)
                self.hbox.addWidget(self.lbl)
                self.mediaQt.photoMediaWidget.setLayout(self.hbox)
                MediaQt.open = False
            self.lbl.setPixmap(pix)
            self.lbl.repaint()

        elif self.fileType in {"mp3"}:
            if not hasattr(self, "player"):
                self.player = QtMultimedia.QMediaPlayer()
            self.player.setMedia(
                QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(
                    self.path)))
            self.hbox = QtWidgets.QHBoxLayout(self.mediaQt.audioMediaWidget)
            self.lbl = QtWidgets.QLabel()
            self.lbl.setAlignment(QtCore.Qt.AlignCenter)
            pix = QtGui.QPixmap()
            pix.load("Icon//mediaWidget//music.png")
            self.lbl.setPixmap(pix)
            self.hbox.addWidget(self.lbl)

        self.slotSignalMusicVideoControlPanel()
 def __init__(self, parent=None):
     super(MainWindow, self).__init__(parent)
     video_widget = QtMultimediaWidgets.QVideoWidget()
     player = QtMultimedia.QMediaPlayer(
         self, QtMultimedia.QMediaPlayer.VideoSurface)
     file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         "video.mp4")
     player.setMedia(
         QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(file)))
     player.setVideoOutput(video_widget)
     player.play()
     self.setCentralWidget(video_widget)
示例#15
0
 def setup(self, display):
     """
     Set up the player widgets
     :param display:
     """
     display.video_widget = QtMultimediaWidgets.QVideoWidget(display)
     display.video_widget.resize(display.size())
     display.media_player = QtMultimedia.QMediaPlayer(display)
     display.media_player.setVideoOutput(display.video_widget)
     display.video_widget.raise_()
     display.video_widget.hide()
     self.has_own_widget = True
示例#16
0
 def __init__(self, camera):
     super().__init__()
     self._camera = camera
     self._camera_viewfinder = QtMultimediaWidgets.QCameraViewfinder()
     self._camera.setCaptureMode(QtMultimedia.QCamera.CaptureStillImage)
     self._image_capture = QtMultimedia.QCameraImageCapture(self._camera)
     self._image_capture.setCaptureDestination(
         QtMultimedia.QCameraImageCapture.CaptureToFile)
     self._tag = None
     self._standard_img = None
     self._current_frame = None
     self._current_image_name = None
示例#17
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.online_webcams = QtMultimedia.QCameraInfo.availableCameras()
        if not self.online_webcams:
            pass  #quit
        self.exist = QtMultimediaWidgets.QCameraViewfinder()
        self.exist.show()
        self.setCentralWidget(self.exist)

        # set the default webcam.
        self.get_webcam(0)
        self.setWindowTitle("WebCam")
        self.show()
 def __init__(self):
     super(Window, self).__init__()
     self.player = QtMultimedia.QMediaPlayer(self)
     self.viewer = QtMultimediaWidgets.QVideoWidget(self)
     self.player.setVideoOutput(self.viewer)
     self.player.stateChanged.connect(self.handleStateChanged)
     self.button1 = QtWidgets.QPushButton('Play', self)
     self.button2 = QtWidgets.QPushButton('Stop', self)
     self.button1.clicked.connect(self.handleButton)
     self.button2.clicked.connect(self.player.stop)
     self.button2.setEnabled(False)
     layout = QtWidgets.QGridLayout(self)
     layout.addWidget(self.viewer, 0, 0, 1, 2)
     layout.addWidget(self.button1, 1, 0)
     layout.addWidget(self.button2, 1, 1)
     self._buffer = QtCore.QBuffer(self)
     self._data = None
示例#19
0
    def start(self):
        OutDebugInfo("start")
        diag = QDialog(self)
        diag.setWindowTitle("Camera")

        # main layout
        diag.lay = QtWidgets.QVBoxLayout()

        # widgets
        diag.capture_button = QtWidgets.QPushButton("Capture")
        diag.capture_button.clicked.connect(self.capture_img)
        diag.label = QtWidgets.QLabel("")

        # setting the device
        diag.device = QCamera.availableDevices()[0]
        diag.m_camera = QCamera(diag.device)

        diag.view_finder = QtMultimediaWidgets.QCameraViewfinder()
        diag.view_finder.setMinimumSize(250, 250)

        diag.m_camera.setViewfinder(diag.view_finder)
        diag.m_camera.setCaptureMode(QCamera.CaptureStillImage)

        try:
            diag.m_camera.start()
            self.startcamera = True

        except:
            pass

        diag.lay.addWidget(diag.label)
        diag.lay.addWidget(diag.view_finder)
        diag.lay.addWidget(diag.capture_button)
        diag.lay.addWidget(diag.label)
        diag.setLayout(diag.lay)

        diag.cp = QCameraImageCapture(diag.m_camera)
        diag.cp.imageCaptured.connect(self.capture_img_handler)
        diag.cp.imageSaved.connect(self.save_img)

        self.capture_diag = diag

        diag.show()
        diag.exec_()
示例#20
0
 def __init__(self, path, parent=None):
     super(videoWidget, self).__init__()
     self.setStyleSheet("QMainWindow {background: 'black';}")
     self.showFullScreen()
     self.setMinimumSize(300, 300)
     self.path = path
     self.widget = QtWidgets.QWidget()
     self.media = QtCore.QUrl.fromLocalFile(self.path)
     self.content = QtMultimedia.QMediaContent(self.media)
     self.player = QtMultimedia.QMediaPlayer()
     self.player.setMedia(self.content)
     self.videoWidget = QtMultimediaWidgets.QVideoWidget()
     # self.layout.addWidget(self.videoWidget)
     self.setCentralWidget(self.videoWidget)
     self.player.setVideoOutput(self.videoWidget)
     self.player.play()
     self.show()
     self.directory = ''
     self.player.mediaStatusChanged.connect(self.closeWhenFinished)
 def __init__(self):
     super(CameraMainWin, self).__init__()
     self.setupUi(self)
     #定义相机实例对象并设置捕获模式
     self.camera = QCamera()
     self.camera.setCaptureMode(QCamera.CaptureViewfinder)
     self.cameraOpened = False  # 设置相机打开状态为未打开
     #设置取景器分辨率
     viewFinderSettings = QCameraViewfinderSettings()
     viewFinderSettings.setResolution(800, 600)
     self.camera.setViewfinderSettings(viewFinderSettings)
     #初始化取景器
     self.viewCamera = QtMultimediaWidgets.QCameraViewfinder(self)
     self.camera.setViewfinder(self.viewCamera)
     self.camerLayout.addWidget(self.viewCamera)  #取景器放置到预留的布局中
     #设置图像捕获
     self.capImg = QCameraImageCapture(self.camera)
     self.capImg.setCaptureDestination(
         QCameraImageCapture.CaptureToFile)  #CaptureToBuffer
示例#22
0
    def mediaplayer(self, path):

        #Create playList and add media
        self.playList = QtMultimedia.QMediaPlaylist()
        # self.playList.addMedia(QtMultimedia.QMediaContent(QtCore.QUrl(path)))
        self.playList.addMedia(
            QtMultimedia.QMediaContent(QtCore.QUrl('file:picture\Rebar.avi')))

        self.playList.setCurrentIndex(1)
        self.playList.setPlaybackMode(
            QtMultimedia.QMediaPlaylist.CurrentItemInLoop)
        #Create player and add playlist to player
        self.player = QtMultimedia.QMediaPlayer()
        self.player.setPlaylist(self.playList)
        #Create play widgets
        self.playerWidgets = QtMultimediaWidgets.QVideoWidget()
        self.playerWidgets.show()
        self.player.setVideoOutput(self.playerWidgets)
        self.player.play()
示例#23
0
 def __init__(self, parent=None):
     super(VideoPlayer, self).__init__(parent)
     
     #self.frame = QtWidgets.QFrame()
     self.setMinimumSize(600, 400)
     self.layout = QtWidgets.QVBoxLayout(self)
     
     self.player = QtMultimedia.QMediaPlayer(self)
     self.player.setAudioRole(QtMultimedia.QAudio.VideoRole)
     
     self.playlist = QtMultimedia.QMediaPlaylist(self.player)
     self.playlist.addMedia(QtMultimedia.QMediaContent(self.playlist, QtCore.QUrl("video.mp4")))
     
     self.video_widget = QtMultimediaWidgets.QVideoWidget(self)
     self.player.setVideoOutput(self.video_widget)
     
     self.layout.addWidget(self.video_widget)
     
     self.video_widget.show()
     self.playlist.setCurrentIndex(1)
     self.player.play()
示例#24
0
    def __init__(self, ancho, alto, parent=None):
        super(VideoPlayer, self).__init__(parent)

        self.setWindowTitle('Reproductor de Video')
        self.resize(ancho, alto)
        self.setWindowIcon(QtGui.QIcon('Recursos/MCServer-icon-64x64.png'))

        openButton = qw.QPushButton("Buscar...")
        openButton.clicked.connect(self.openFile)

        self.playButton = qw.QPushButton()
        self.playButton.setEnabled(False)
        self.playButton.setIcon(self.style().standardIcon(
            qw.QStyle.SP_MediaPlay))
        self.playButton.clicked.connect(self.play)

        self.positionSlider = qw.QSlider(qc.Qt.Horizontal)
        self.positionSlider.setRange(0, 0)
        self.positionSlider.sliderMoved.connect(self.setPosition)

        controlLayout = qw.QHBoxLayout()
        controlLayout.setContentsMargins(0, 0, 0, 0)
        controlLayout.addWidget(openButton)
        controlLayout.addWidget(self.playButton)
        controlLayout.addWidget(self.positionSlider)

        videoWidget = qmultiWid.QVideoWidget()

        layout = qw.QVBoxLayout()
        layout.addWidget(videoWidget)
        layout.addLayout(controlLayout)

        self.setLayout(layout)

        self.mediaPlayer = qmulti.QMediaPlayer(
            None, qmulti.QMediaPlayer.VideoSurface)
        self.mediaPlayer.setVideoOutput(videoWidget)
        self.mediaPlayer.stateChanged.connect(self.mediaStateChanged)
        self.mediaPlayer.positionChanged.connect(self.positionChanged)
        self.mediaPlayer.durationChanged.connect(self.durationChanged)
示例#25
0
 def __init__(self):
     super(XrecogCaptureWindow, self).__init__()
     uic.loadUi(translatePath("capture.ui"), self)
     self.images = []
     self.imageSlots = []
     self.selected_camera = None
     self.camera = None
     self.capture = None
     self.hasInit = False
     slots = [
         self.imageGrid.findChildren(
             QtWidgets.QWidget, QtCore.QRegExp("imageSlot%02d" % index))[0]
         for index in range(1, 13)
     ]
     for slot in slots:
         newSizePolicy = slot.sizePolicy()
         newSizePolicy.setRetainSizeWhenHidden(True)
         slot.setSizePolicy(newSizePolicy)
         slot.setAttribute(QtCore.Qt.WA_Hover)
         slot.installEventFilter(self)
         slot.hide()
         imageSlot = slot.findChild(QtWidgets.QLabel)
         imageToolbar = slot.findChildren(
             QtWidgets.QHBoxLayout,
             QtCore.QRegExp("imageSlotToolBar\d{2}"))[0]
         previewButton = slot.findChildren(
             QtWidgets.QToolButton,
             QtCore.QRegExp("viewImageButton\d{2}"))[0]
         deleteButton = slot.findChildren(
             QtWidgets.QToolButton, QtCore.QRegExp("deleteButton\d{2}"))[0]
         previewButton.hide()
         deleteButton.hide()
         slotObject = {"object": slot, "item": None}
         previewButton.clicked.connect(self.newPreviewHandler(slotObject))
         deleteButton.clicked.connect(self.newDeleteHandler(slotObject))
         self.imageSlots.append(slotObject)
     self.imagepreviewer = XrecogImagePreviewDialog(self)
     self.viewfinder = QtMultimediaWidgets.QCameraViewfinder()
     self.viewFinderFrame.layout().addWidget(self.viewfinder)
     self.installEventFilter(self)
示例#26
0
    def __init__(self, parent=None):
        super().__init__(parent)

        le = QtWidgets.QLineEdit()

        view = QtWebEngineWidgets.QWebEngineView()
        view.load(QtCore.QUrl("https://www.youtube.com/"))

        video_filename = os.path.join(resources_dir, "big_buck_bunny_720p_30mb.mp4")
        player = QtMultimedia.QMediaPlayer(self)
        player.setMedia(
            QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(video_filename))
        )
        videowidget = QtMultimediaWidgets.QVideoWidget()
        player.setVideoOutput(videowidget)
        player.play()

        lay = QtWidgets.QVBoxLayout(self)
        lay.addWidget(le)
        lay.addWidget(view, stretch=1)
        lay.addWidget(videowidget, stretch=1)
        self.resize(640, 480)
示例#27
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.history_model = QtGui.QStandardItemModel(self)
        self.history_completer = QtWidgets.QCompleter(self)
        self.history_completer.setModel(self.history_model)

        self.pipeline_le = QtWidgets.QLineEdit()
        self.pipeline_le.setCompleter(self.history_completer)
        self.play_btn = QtWidgets.QPushButton(self.tr("&Play"))

        for text in (
            ('gst-pipeline: videotestsrc ! xvimagesink name="qtvideosink"'),
            (
                'gst-pipeline: v4l2src device="/dev/video0" ! video/x-raw,width=640,height=480 ! xvimagesink name="qtvideosink"'  # noqa: E501
            ),
            ('gst-pipeline: ximagesrc ! videoconvert ! xvimagesink name="qtvideosink"'
             ),
        ):
            it = QtGui.QStandardItem(text)
            self.history_model.appendRow(it)

        self.video_widget = QtMultimediaWidgets.QVideoWidget()
        self.player = QtMultimedia.QMediaPlayer(
            self, QtMultimedia.QMediaPlayer.VideoSurface)
        self.player.error.connect(self.on_error)
        self.player.setVideoOutput(self.video_widget)

        self.play_btn.clicked.connect(self.on_clicked)

        central_widget = QtWidgets.QWidget()
        self.setCentralWidget(central_widget)
        grid_layout = QtWidgets.QGridLayout(central_widget)
        grid_layout.addWidget(QtWidgets.QLabel(self.tr("<b>Url:</b>")), 0, 0)
        grid_layout.addWidget(self.pipeline_le, 0, 1)
        grid_layout.addWidget(self.play_btn, 0, 2)
        grid_layout.addWidget(self.video_widget, 1, 0, 1, 3)

        self.resize(640, 480)
    def __init__(self):
        super(MyWindow, self).__init__()
        self.setGeometry(0, 0, 1920, 1080)
        self.setWindowTitle("BF4 Deployment Timer")

        # Video Background

        self.videoWidget = QtMultimediaWidgets.QVideoWidget()
        self.setCentralWidget(self.videoWidget)

        self.mediaPlayer = QtMultimedia.QMediaPlayer(
            None, QtMultimedia.QMediaPlayer.VideoSurface)
        self.mediaPlayer.setVideoOutput(self.videoWidget)

        local = QtCore.QUrl.fromLocalFile(
            'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/vidbackground2.mov'
        )
        media = QtMultimedia.QMediaContent(local)
        self.mediaPlayer.setMedia(media)
        self.mediaPlayer.play()

        self.initUI()
示例#29
0
 def __init__(self, ddir, parent=None):
     super().__init__(parent)
     self.setGeometry(0, 0, col10, row10)
     self.setWindowFlags(Qt.FramelessWindowHint)
     self.setAttribute(Qt.WA_NoSystemBackground, True)
     self.ddir = ddir
     self.clips = [
         "{}/{}".format(ddir, name) for name in os.listdir(str(ddir))
         if name.endswith(".mp4") or name.endswith('.mkv')
     ]
     self.video_widget = QtMultimediaWidgets.QVideoWidget()
     self.video_widget.setGeometry(0, 0, col10, row10)
     self.player = QtMultimedia.QMediaPlayer()
     self.player.setVideoOutput(self.video_widget)
     layout = QVBoxLayout(self)
     layout.addWidget(self.video_widget)
     self.playlist = QtMultimedia.QMediaPlaylist()
     self.addMedia()
     self.playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop)
     self.player.setPlaylist(self.playlist)
     self.timer = QTimer(self)
     self.timer.timeout.connect(self.check_videos)
     self.timer.start(10000)
示例#30
0
    def __init__(self, parent=None):
        super(Viewfinder, self).__init__(parent=parent)

        self.camera = None
        self.recordDir = os.path.expanduser('~')

        self.scene = QtWidgets.QGraphicsScene()
        self.scene.setBackgroundBrush(QtCore.Qt.black)
        self.setScene(self.scene)

        # Camera preview
        self.preview = QtMultimediaWidgets.QGraphicsVideoItem()
        self.scene.addItem(self.preview)

        # Record and stop button. The record button is initially added to the scene.
        self.stopItem = ButtonItem(
            pkgutil.get_data('webrec', 'resources/stop_icon.png'))
        self.stopItem.signalSource.clicked.connect(self.stopClicked)
        self.recordItem = ButtonItem(
            pkgutil.get_data('webrec', 'resources/record_icon.png'))
        self.recordItem.signalSource.clicked.connect(self.recordClicked)
        self.scene.addItem(self.recordItem)

        self.resize(self.width(), self.height())