示例#1
0
    def __init__(self, fila, pantallaTotal=True, parent=None):
        #super(InterfazVideo, self).__init__(parent)
        QtGui.QWidget.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint)
        # Parámetros constantes:
        self.titulo = 'Scape Room'
        self.thread = ThreadClass()
        self.video1 = Phonon.VideoPlayer(self)
        self.video2 = Phonon.VideoPlayer(self)
        self.thread.start()
        self.miPopUp = PopUp()

        self.queue = fila
        self.passwords = []
        with open('./database/key', 'r') as f:
            readData = f.read()
        for password in readData.split('\n'):
            if len(password) > 4:
                self.passwords.append(password)
        # Clases auxiliares:
        self.initUI()
        self.connect(self.thread, QtCore.SIGNAL('REVISAR'),
                     self.revisarRespuesta)
        self.connect(self.video1, QtCore.SIGNAL("finished()"),
                     self._terminoVideo)
        self.connect(self.video2, QtCore.SIGNAL("finished()"),
                     self._terminoVideo)
        self.connect(self.thread, QtCore.SIGNAL("ACTUALIZAR"),
                     self.actualizarTexto)
        self.intro.returnPressed.connect(self.revisarRespuesta)
        # Al inicializarse la clase se muestra:
        if pantallaTotal:
            self.showFullScreen()
        else:
            self.show()
示例#2
0
def run(image_folder):
	#image_folder = 'images'
	video_name = 'video.avi'

	images = [img for img in os.listdir(image_folder) if img.endswith(".png")]
	frame = cv2.imread(os.path.join(image_folder, images[0]))
	height, width, layers = frame.shape

	video = cv2.VideoWriter(video_name,cv2.VideoWriter_fourcc('M','J','P','G'),1, (width,height))

	for image in images:
		video.write(cv2.imread(os.path.join(image_folder, image)))

	cv2.destroyAllWindows()
	video.release()


	app = QtGui.QApplication(sys.argv)
	vp = Phonon.VideoPlayer()
	vp.show()
	media = Phonon.MediaSource('video.avi')
	vp.load(media)
	vp.play()
	vp.move(200,100)
	vp.setGeometry(50,50, 600, 600)
	sys.exit(app.exec_())
    def __init__(self, url, parent=None):

        self.url = url

        QtGui.QWidget.__init__(self, parent)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Preferred)

        self.player = Phonon.VideoPlayer(Phonon.VideoCategory, self)
        self.player.load(Phonon.MediaSource(self.url))
        self.player.mediaObject().setTickInterval(100)
        self.player.mediaObject().tick.connect(self.tock)

        self.play_pause = QtGui.QPushButton(self)
        self.play_pause.setText("Play")
        #self.play_pause.setIcon(QtGui.QIcon(':/icons/player_play.svg'))
        self.play_pause.clicked.connect(self.playClicked)
        self.player.mediaObject().stateChanged.connect(self.stateChanged)

        self.slider = Phonon.SeekSlider(self.player.mediaObject(), self)

        self.status = QtGui.QLabel(self)
        self.status.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)

        self.download = QtGui.QPushButton("Download", self)
        self.download.clicked.connect(self.fetch)
        topLayout = QtGui.QVBoxLayout(self)
        topLayout.addWidget(self.player)
        layout = QtGui.QHBoxLayout(self)
        layout.addWidget(self.play_pause)
        layout.addWidget(self.slider)
        layout.addWidget(self.status)
        layout.addWidget(self.download)
        topLayout.addLayout(layout)
        self.setLayout(topLayout)
示例#4
0
文件: player.py 项目: xOpenLee/python
def main():
    app = QtGui.QApplication(sys.argv)
    vp = Phonon.VideoPlayer()
    media = Phonon.MediaSource("Eason.mp4")
    vp.show()
    vp.load(media)
    vp.play()
    sys.exit(app.exec_())
示例#5
0
    def __init__(self, fullscreen):
        self.subject = []
        self.condition = []
        self.soft_rules = []

        QtGui.QWidget.__init__(self)
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)
        layout.setContentsMargins(20, 20, 20, 20)
        
        if fullscreen:
            screen_H = QDesktopWidget().screenGeometry().height()
        else:
            screen_H = MAIN_WINDOW_HEIGHT

        # Top Horizontal Layout (with Home Button)
        hori_layout = QtGui.QHBoxLayout()
        hori_layout.setSizeConstraint(QLayout.SetDefaultConstraint)
        hori_layout.addStretch(1)
        exit_btn = QtGui.QPushButton("Home")
        size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed)
        exit_btn.setSizePolicy(size_policy)
        hori_layout.addWidget(exit_btn)

        # Main Layout - StackedWidget : Wait Label / Video Player
        layout.addLayout(hori_layout)
        self.stacked_widget = QtGui.QStackedWidget()
        page_title = QtGui.QLabel("Training")
        size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        page_title.setSizePolicy(size_policy)
        page_title.setAlignment(QtCore.Qt.AlignCenter)
        layout.addWidget(page_title)
        spacer_vert = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)
        layout.addItem(spacer_vert)
        # Video player
        self.vid_player = Phonon.VideoPlayer()
        self.vid_player.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.vid_player.setFixedHeight(screen_H/RATIO_SCREEN_H_TRAINING_H)
        # Image for starting video
        self.wait_label = WaitLabel()
        self.wait_label.clicked_sig.connect(self.clicked_sig_received)
        self.wait_label.setFixedHeight(screen_H/RATIO_SCREEN_H_TRAINING_H)
        self.stacked_widget.addWidget(self.wait_label)
        self.stacked_widget.addWidget(self.vid_player)
        size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        self.stacked_widget.setSizePolicy(size_policy)
        layout.addWidget(self.stacked_widget)
        self.setMaximumHeight(screen_H)   
        layout.addItem(spacer_vert)
        
        # Position in training videos
        self.cur_vid_num = 0
        # Video Player  
        self.vid_player.finished.connect(self.setnextvideo)

        exit_btn.clicked.connect(self.exittraining)
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.player = Phonon.VideoPlayer(Phonon.VideoCategory, self)
        self.createVideoUI()
        self.createPlotUI()
        self.createLayout()
        self.isPaused = False
        self.filename = None
        self.xmax = None
        self.nframes = None
示例#7
0
    def __init__(self, directory, x, y, width, height):
        QtGui.QMainWindow.__init__(self)
        widget = QtGui.QWidget()
        layout = QtGui.QVBoxLayout()
        widget.setLayout(layout)
        self.setCentralWidget(widget)
        self.setGeometry(x, y, width, height)

        self.player = Phonon.VideoPlayer(widget)
        layout.addWidget(self.player)

        #vpWidget = Phonon.VideoWidget()
        mediaObject = Phonon.MediaObject()

        self.mediaSrc = Phonon.MediaSource(directory)
        self.player.play(self.mediaSrc)
        self.show()
示例#8
0
def vid_player(vid_dir):
    """Alternate video player method

    Args:
        vid_dir (str): Path to the video
    """
    app = QtGui.QApplication(sys.argv)
    vp = Phonon.VideoPlayer()
    media = Phonon.MediaSource('F:\\video.mp4')
    vp.load(media)
    vp.play()
    videoWidget = vp.videoWidget()
    if videoWidget.isFullScreen():
        videoWidget.exitFullScreen()
    else:
        videoWidget.enterFullScreen()
    vp.show()
    sys.exit(app.exec_())
示例#9
0
def create_animation_widget(screen_h):
    # Create the Phonon video player
    animation_player = Phonon.VideoPlayer()
    animation_player.setStyleSheet("QLabel {background-color:blue}")
    size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                    QtGui.QSizePolicy.Preferred)
    animation_player.setSizePolicy(size_policy)
    # The animation size is a square
    animation_player.setFixedSize(screen_h / RATIO_SCREEN_H_ANIMATION_H,
                                  screen_h / RATIO_SCREEN_H_ANIMATION_H)
    animation_widget = QtGui.QWidget()
    animation_layout = QtGui.QHBoxLayout()
    spacer_item_1 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding,
                                      QtGui.QSizePolicy.Minimum)
    spacer_item_2 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding,
                                      QtGui.QSizePolicy.Minimum)
    animation_layout.addItem(spacer_item_1)
    animation_layout.addWidget(animation_player)
    animation_layout.addItem(spacer_item_2)
    animation_widget.setLayout(animation_layout)
    return animation_player, animation_widget
示例#10
0
    def setup_ui(self, media_file_name):
        self.player = Phonon.VideoPlayer(Phonon.VideoCategory, parent=self)
        self.player.load(Phonon.MediaSource(media_file_name))

        media_object = self.player.mediaObject()
        media_object.setTickInterval(100)
        media_object.stateChanged.connect(self.state_changed)

        self.play_pause_button = QtGui.QPushButton(">")
        self.play_pause_button.clicked.connect(self.play_clicked)

        self.slider = Phonon.SeekSlider(self.player.mediaObject(), parent=self)

        topLayout = QtGui.QVBoxLayout(self)
        topLayout.addWidget(self.player)

        layout = QtGui.QHBoxLayout(self)
        layout.addWidget(self.play_pause_button)
        layout.addWidget(self.slider)

        topLayout.addLayout(layout)

        self.setLayout(topLayout)
示例#11
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        widget = QtGui.QWidget()
        layout = QtGui.QVBoxLayout()
        widget.setLayout(layout)

        self.setCentralWidget(widget)

        self.player = Phonon.VideoPlayer()
        layout.addWidget(self.player)
        self.player.setMinimumSize(400, 400)

        start = QtGui.QPushButton('Start')
        stop = QtGui.QPushButton('Stop')
        bye = QtGui.QPushButton('Exit')

        start.clicked.connect(self.select_and_play)
        stop.clicked.connect(self.stop_play)
        bye.clicked.connect(self.hastalavista)

        layout.addWidget(start)
        layout.addWidget(stop)
        layout.addWidget(bye)
示例#12
0
    def __init__(self, url=None, parent=None):
        self.url = ''
        QWidget.__init__(self, parent)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.player = Phonon.VideoPlayer(Phonon.VideoCategory, self)
        self.player.setMinimumSize(640, 360)
        self.player.mediaObject().setTickInterval(100)
        self.player.mediaObject().tick.connect(self.tock)

        self.play_pause = QPushButton(self)
        self.play_pause.setIcon(QIcon(':/play.png'))
        self.play_pause.released.connect(self.playClicked)

        self.stop = QPushButton(self)
        self.stop.setIcon(QIcon(':/stop.png'))
        self.stop.clicked.connect(self.stopClicked)

        self.player.mediaObject().stateChanged.connect(self.stateChanged)

        self.slider = Phonon.SeekSlider(self.player.mediaObject(), self)

        self.status = QLabel(self)
        self.status.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

        self.volume = Phonon.VolumeSlider(self.player.audioOutput(), self)

        topLayout = QVBoxLayout(self)
        topLayout.addWidget(self.player, 2)
        layout = QHBoxLayout(self)
        layout.addWidget(self.play_pause)
        layout.addWidget(self.stop)
        layout.addWidget(self.slider, 2)
        layout.addWidget(self.status)
        layout.addWidget(self.volume)
        topLayout.addLayout(layout)
        self.setLayout(topLayout)
示例#13
0
import sys
from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon

app = QtGui.QApplication(sys.argv)
vp = Phonon.VideoPlayer()
media = Phonon.MediaSource("i.mpg")
vp.load(media)
vp.play()
vp.show()

app.exec_()
示例#14
0
    def video_player_config(self):
        # =====================================================================
        # Configure Video Player related Config
        # =====================================================================

        #Array of Paths (None Indicates Path Unknown)
        self.video_paths = [None, None, None, None]

        #Array of Players and Layouts
        self.player = [
            Phonon.VideoPlayer(Phonon.VideoCategory, self),
            Phonon.VideoPlayer(Phonon.VideoCategory, self),
            Phonon.VideoPlayer(Phonon.VideoCategory, self),
            Phonon.VideoPlayer(Phonon.VideoCategory, self)
        ]

        self.video_layouts = [
            self.ui.video_layout0, self.ui.video_layout1,
            self.ui.video_layout2, self.ui.video_layout3
        ]

        self.video_bg = [
            self.ui.vid_bg0, self.ui.vid_bg1, self.ui.vid_bg2, self.ui.vid_bg3
        ]

        #Add Player to Layouts
        for index in range(len(self.player)):
            self.video_layouts[index].addWidget(self.player[index])
            self.player[index].load(Phonon.MediaSource('/'))
            self.player[index].installEventFilter(self)

        #Plays Video in Infinite Repeat Mode
        self.player[0].mediaObject().aboutToFinish.connect(
            lambda: self.player[0].seek(0))
        self.player[1].mediaObject().aboutToFinish.connect(
            lambda: self.player[1].seek(0))
        self.player[2].mediaObject().aboutToFinish.connect(
            lambda: self.player[2].seek(0))
        self.player[3].mediaObject().aboutToFinish.connect(
            lambda: self.player[3].seek(0))

        #Full Screen Handlers
        self.ui.full_screen0.pressed.connect(
            lambda: self.show_full_screen_video(0))
        self.ui.full_screen1.pressed.connect(
            lambda: self.show_full_screen_video(1))
        self.ui.full_screen2.pressed.connect(
            lambda: self.show_full_screen_video(2))
        self.ui.full_screen3.pressed.connect(
            lambda: self.show_full_screen_video(3))

        #Full Screen Exit Handler
        close_full_screenSC = QShortcut(self)
        close_full_screenSC.setKey(QKeySequence('Esc'))
        close_full_screenSC.setContext(Qt.ApplicationShortcut)
        close_full_screenSC.activated.connect(self.close_full_screen_video)

        self.ui.snapshot0.clicked.connect(lambda: self.video_snapshot(0))
        self.ui.snapshot1.clicked.connect(lambda: self.video_snapshot(1))
        self.ui.snapshot2.clicked.connect(lambda: self.video_snapshot(2))
        self.ui.snapshot3.clicked.connect(lambda: self.video_snapshot(3))

        #LCD Timer Configuration
        self.lcd_timers = [
            self.ui.lcd_timer0, self.ui.lcd_timer1, self.ui.lcd_timer2,
            self.ui.lcd_timer3
        ]
示例#15
0
 def setupUi(self, MainWindow, Env):
     #This sets up the main menu with a size of 1024 by 768, the required
     #size as per our requirements. As a note, everything after the variable
     #name is python bindings to QT4, so any questions can be looked up in
     #the QT4 documentation, which is in C.
     self.Env = Env
     MainWindow.setObjectName("MainWindow")
     bb = Env[2].desktop().size()
     self.MW = MainWindow
     self.videoPlayer = Phonon.VideoPlayer(self.MW)
     self.videoPlayer.setGeometry(QtCore.QRect(0, 0, bb.width(), bb.height()))
     self.videoPlayer.setObjectName("videoPlayer")
     self.tabWidget = QtGui.QGraphicsView(self.MW)
     self.tabWidget.setGeometry(QtCore.QRect(400, 300, 551, 351))
     self.tabWidget.setObjectName("tabWidget")
     self.PlayerNumberSB = QtGui.QSpinBox(self.tabWidget)
     self.PlayerNumberSB.setGeometry(QtCore.QRect(180, 100, 42, 22))
     self.PlayerNumberSB.setFocusPolicy(QtCore.Qt.NoFocus)
     self.PlayerNumberSB.setLayoutDirection(QtCore.Qt.LeftToRight)
     self.PlayerNumberSB.setReadOnly(False)
     self.PlayerNumberSB.setButtonSymbols(QtGui.QAbstractSpinBox.UpDownArrows)
     self.PlayerNumberSB.setMinimum(1)
     self.PlayerNumberSB.setMaximum(8)
     self.PlayerNumberSB.setObjectName("PlayerNumberSB")
     self.label = QtGui.QLabel(self.tabWidget)
     self.label.setGeometry(QtCore.QRect(40, 100, 91, 16))
     self.label.setScaledContents(True)
     self.label.setObjectName("label")
     self.label_2 = QtGui.QLabel(self.tabWidget)
     self.label_2.setGeometry(QtCore.QRect(40, 60, 61, 16))
     self.label_2.setMargin(1)
     self.label_2.setObjectName("label_2")
     self.GameNameLE = QtGui.QLineEdit(self.tabWidget)
     self.GameNameLE.setEnabled(True)
     self.GameNameLE.setGeometry(QtCore.QRect(110, 60, 113, 20))
     self.GameNameLE.setObjectName("GameNameLE")
     self.LoadGamesTable = QtGui.QTableWidget(self.tabWidget)
     self.LoadGamesTable.setGeometry(QtCore.QRect(0, 160, 421, 101))
     self.LoadGamesTable.setFrameShape(QtGui.QFrame.StyledPanel)
     self.LoadGamesTable.setFrameShadow(QtGui.QFrame.Sunken)
     self.LoadGamesTable.setLineWidth(3)
     self.LoadGamesTable.setMidLineWidth(2)
     self.LoadGamesTable.setAlternatingRowColors(True)
     self.LoadGamesTable.setGridStyle(QtCore.Qt.DashDotLine)
     self.LoadGamesTable.setWordWrap(False)
     self.LoadGamesTable.setObjectName("LoadGamesTable")
     self.LoadGamesTable.setColumnCount(0)
     self.LoadGamesTable.setRowCount(0)
     self.groupBox = QtGui.QGroupBox(self.tabWidget)
     self.groupBox.setGeometry(QtCore.QRect(10, 20, 91, 161))
     self.groupBox.setFocusPolicy(QtCore.Qt.TabFocus)
     self.groupBox.setFlat(True)
     self.groupBox.setCheckable(False)
     self.groupBox.setObjectName("groupBox")
     self.LoadGameRB = QtGui.QRadioButton(self.groupBox)
     self.LoadGameRB.setGeometry(QtCore.QRect(0, 110, 82, 17))
     self.LoadGameRB.setObjectName("LoadGame")
     self.StartGameRB = QtGui.QRadioButton(self.groupBox)
     self.StartGameRB.setGeometry(QtCore.QRect(10, 20, 82, 17))
     self.StartGameRB.setChecked(True)
     self.StartGameRB.setObjectName("StartGameRB")
     self.OkButton = QtGui.QPushButton(self.MW)
     self.OkButton.setGeometry(QtCore.QRect(470, 690, 75, 23))
     self.OkButton.setObjectName("OkButton")
     self.QuitButton = QtGui.QPushButton(self.MW)
     self.QuitButton.setGeometry(QtCore.QRect(840, 690, 75, 23))
     self.QuitButton.setObjectName("QuitButton")
     #below here sets up the A/V of the main menu. videoPlayer is the qt/Phonon back end that
     #plays videos. Might have some trouble with file types on linux. While soundPlayer is a
     #bit more complicated. The sound player is the player for the sound, it handles the playing
     #and stopping. The sound is the audioOutput, which controls volume and other internals.
     #They are mapped together with the Path = Phonon.createPath().
     self.soundPlayer = Phonon.MediaObject(self.MW)
     self.soundPlayer.setCurrentSource(Phonon.MediaSource("des.mp3"))
     self.sound = Phonon.AudioOutput(Phonon.MusicCategory, self.MW)
     Path = Phonon.createPath(self.soundPlayer, self.sound)
     self.soundPlayer.play()
     self.videoPlayer.play(Phonon.MediaSource("tab2.avi"))
     self.retranslateUi(self.MW)
     #These are the signals that connect the buttons to functions. First part is always?
     #the same. The next part is the widget that sends the signal. Next is the signal sent.
     #Be sure to include any variables if the signal sends them. Last is the function to be
     #called
     QtCore.QObject.connect(self.OkButton, QtCore.SIGNAL("clicked()"), self.OkClicked)
     QtCore.QObject.connect(self.QuitButton, QtCore.SIGNAL("clicked()"), self.ExitOut)
     QtCore.QObject.connect(self.videoPlayer, QtCore.SIGNAL("finished()"), self.Replay)
     QtCore.QObject.connect(self.soundPlayer, QtCore.SIGNAL("aboutToFinish()"), self.ReplaySound)
     QtCore.QMetaObject.connectSlotsByName(MainWindow)