Ejemplo n.º 1
0
    def setupUi(self):
        bar = QtGui.QToolBar()

        bar.addAction(self.playAction)
        bar.addAction(self.pauseAction)
        bar.addAction(self.stopAction)

        self.seekSlider = Phonon.SeekSlider(self)
        self.seekSlider.setMediaObject(self.mediaObject)

        self.volumeSlider = Phonon.VolumeSlider(self)
        self.volumeSlider.setAudioOutput(self.audioOutput)
        self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum,
                                        QtGui.QSizePolicy.Maximum)

        volumeLabel = QtGui.QLabel()
        volumeLabel.setPixmap(QtGui.QPixmap('images/volume.png'))

        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkGray)

        self.timeLcd = QtGui.QLCDNumber()
        self.timeLcd.setPalette(palette)

        headers = [
            self.tr("Title"),
            self.tr("Artist"),
            self.tr("Album"),
            self.tr("Year")
        ]

        self.musicTable = QtGui.QTableWidget(0, 4)
        self.musicTable.setHorizontalHeaderLabels(headers)
        self.musicTable.setSelectionMode(
            QtGui.QAbstractItemView.SingleSelection)
        self.musicTable.setSelectionBehavior(
            QtGui.QAbstractItemView.SelectRows)
        self.connect(self.musicTable, QtCore.SIGNAL('cellPressed(int, int)'),
                     self.tableClicked)

        seekerLayout = QtGui.QHBoxLayout()
        seekerLayout.addWidget(self.seekSlider)
        seekerLayout.addWidget(self.timeLcd)

        playbackLayout = QtGui.QHBoxLayout()
        playbackLayout.addWidget(bar)
        playbackLayout.addStretch()
        playbackLayout.addWidget(volumeLabel)
        playbackLayout.addWidget(self.volumeSlider)

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.musicTable)
        mainLayout.addLayout(seekerLayout)
        mainLayout.addLayout(playbackLayout)

        widget = QtGui.QWidget()
        widget.setLayout(mainLayout)

        self.setCentralWidget(widget)
        self.setWindowTitle("Phonon Music Player")
Ejemplo n.º 2
0
    def setupUI(self):
        """UI生成シーケンス.
        可視性を高めるため別に記述
        """

        # Ctrl UI
        self.btn_start = QPushButton('PLAY', self)
        self.volume_slider = Phonon.VolumeSlider(self)
        self.volume_slider.setAudioOutput(self.audio)
        self.seek_slider = Phonon.SeekSlider(self.media, self)
        self.seek_slider.setSingleStep(1 / 30 * 1000)  # [ms]

        # Status Label
        self.status_label = QLabel("00:00:00", self)
        self.status_label.setAlignment(Qt.AlignRight | Qt.AlignCenter)

        # Layout
        layout = QGridLayout(self)
        # 一段目
        layout.addWidget(self.btn_start, 0, 0)
        layout.addWidget(self.volume_slider, 0, 1)
        layout.addWidget(self.status_label, 0, 2)
        # 二段目
        layout.addWidget(self.seek_slider, 1, 0, 1, 3)

        # Signal
        self.media.stateChanged.connect(self._handle_StateChanged)
        self.media.aboutToFinish.connect(self.restart)
        self.btn_start.clicked.connect(self._handle_BtnStart)
Ejemplo n.º 3
0
 def __init__(self, parent=None):
     QMainWindow.__init__(self, parent)
     self.setWindowFilePath('No file')
     # the media object controls the playback
     self.media = Phonon.MediaObject(self)
     # the audio output does the actual sound playback
     self.audio_output = Phonon.AudioOutput(Phonon.MusicCategory, self)
     # a slider to seek to any given position in the playback
     self.seeker = Phonon.SeekSlider(self)
     self.setCentralWidget(self.seeker)
     # link media objects together.  The seeker will seek in the created
     # media object
     self.seeker.setMediaObject(self.media)
     # audio data from the media object goes to the audio output object
     Phonon.createPath(self.media, self.audio_output)
     # set up actions to control the playback
     self.actions = self.addToolBar('Actions')
     for name, label, icon_name in self.ACTIONS:
         icon = self.style().standardIcon(icon_name)
         action = QAction(icon, label, self)
         action.setObjectName(name)
         self.actions.addAction(action)
         if name == 'open':
             action.triggered.connect(self._ask_open_filename)
         else:
             action.triggered.connect(getattr(self.media, name))
     # whenever the playback state changes, show a message to the user
     self.media.stateChanged.connect(self._show_state_message)
Ejemplo n.º 4
0
 def setup(self, parent):
     self.media = Phonon.MediaObject(parent)
     videoWidget = Phonon.VideoWidget(parent)
     Phonon.createPath(self.media, videoWidget)
     self.layout().addWidget(videoWidget)
     self.seekSlider = Phonon.SeekSlider(self.media, parent)
     self.layout().addWidget(self.seekSlider)
     self.seekSlider.setIconVisible(False)
     self.media.finished.connect(self.mediaFinished)
Ejemplo n.º 5
0
    def __init__(self):
        #QtGui.QWidget.__init__(self)
        super(QPlayer, self).__init__()
        self.audioOuptut = Phonon.AudioOutput(Phonon.MusicCategory, self)
        self.player = Phonon.MediaObject(self)
        Phonon.createPath(self.player, self.audioOuptut)

        self.videoWidget = Phonon.VideoWidget(self)
        Phonon.createPath(self.player, self.videoWidget)

        self.player.setTickInterval(1000)
        self.connect(self.player, QtCore.SIGNAL("tick(qint64)"), self.tick)

        self.seekSlider = Phonon.SeekSlider(self.player, self)
        self.volumeSlider = Phonon.VolumeSlider(self.audioOuptut, self)

        self.buildGUI()
        self.setupConnections()
    def __init__(self, settings):
        super(QPlayer, self).__init__()
        self.audioOuptut = Phonon.AudioOutput(Phonon.MusicCategory, self)
        self.player = Phonon.MediaObject(self)
        Phonon.createPath(self.player, self.audioOuptut)

        self.videoWidget = cVideoWidget()
        Phonon.createPath(self.player, self.videoWidget)

        self.player.setTickInterval(500)  #1000
        self.connect(self.player, QtCore.SIGNAL("tick(qint64)"), self.tick)

        self.seekSlider = Phonon.SeekSlider(self.player, self)
        self.volumeSlider = Phonon.VolumeSlider(self.audioOuptut, self)
        #self.volumeSlider.setMaximumVolume(0.35)

        self.buildGUI()
        self.setupConnections()
        self.init = True  # used to test before loading file when PLAY is pushed
Ejemplo n.º 7
0
    def setupUi(self):

        styles = """
          QSlider::groove:horizontal {
             background: red;
             position: absolute; /* absolutely position 4px from the left and right of the widget. setting margins on the widget should work too... */
             left: 4px; right: 4px;
             height:4px;
         }

         QSlider::handle:horizontal {
             height: 6px;
             width: 6px;
             background: red;
             
             border-radius: 100px;
         }

         QSlider::add-page:horizontal {
             background: white;
         }

         QSlider::sub-page:horizontal {
             background: skyblue;
         }
        """

        self.seekSlider = Phonon.SeekSlider(self.media, self)
        self.seekSlider.setStyleSheet(styles)
        self.volumeSlider = Phonon.VolumeSlider(self.audio)

        palette = QPalette()
        palette.setBrush(QPalette.Dark, Qt.lightGray)

        self.timeLcd = QLCDNumber()
        self.timeLcd.setPalette(palette)


        headers = [self.tr("Title"), self.tr("Duration")]

        self.playlistTable = QTableWidget(0, 2)
        self.playlistTable.setHorizontalHeaderLabels(headers)
        self.playlistTable.setSelectionMode(QAbstractItemView.SingleSelection)
        self.playlistTable.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.playlistTable.setStyleSheet('background-color: #ffffff; color: #000000')
        self.playlistTable.setMinimumWidth(250)


        self.connect(self.playlistTable, SIGNAL('cellPressed(int, int)'),
                self.tableClicked)

        playlistBar = QToolBar()
        playlistBar.addAction(self.addFilesAction)
        playlistBar.addAction(self.repeatListAction)
        playlistBar.addAction(self.shuffleAction)
        playlistBar.addAction(self.previousAction)
        playlistBar.addAction(self.nextAction)
        playlistBar.setStyleSheet('QToolBar{border-color:#cccccc;}QToolButton:checked{background-color:blue}')

        playlistLayout = QVBoxLayout()
        playlistLayout.addWidget(self.playlistTable)
        playlistLayout.addWidget(playlistBar)
        
        self.playlistWidget = QWidget()
        self.playlistWidget.setLayout(playlistLayout)


        bar = QToolBar()
        bar.addAction(self.playAction)
        bar.addAction(self.pauseAction)
        bar.addAction(self.stopAction)
        bar.addAction(self.fullAction)
        bar.addAction(self.repeatAction)
        bar.setStyleSheet('QToolBar{border-color:#cccccc;}QToolButton:checked{background-color:blue}')

        listbar = QToolBar()
        listbar.addAction(self.addFilesAction)
        listbar.addAction(self.playlistAcion)

        listbar.setStyleSheet('QToolBar {border-color:#cccccc;}')


        self.video.setMinimumWidth(400)

        videoLayout = QHBoxLayout()
        videoLayout.addWidget(self.video)
        videoLayout.addWidget(self.playlistWidget)


        seekerLayout = QHBoxLayout()
        seekerLayout.addWidget(self.seekSlider)
        seekerLayout.addWidget(self.timeLcd)

        playbackLayout = QHBoxLayout()
        playbackLayout.addWidget(bar)
        playbackLayout.addStretch()
        playbackLayout.addWidget(listbar)
        playbackLayout.addWidget(self.volumeSlider)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(videoLayout)
        mainLayout.addLayout(seekerLayout)
        mainLayout.addLayout(playbackLayout)

        self.widget = QWidget()
        self.widget.setLayout(mainLayout)
        self.widget.setStyleSheet('background-color: #000000;')
        self.widget.setMinimumWidth(200)



        self.setCentralWidget(self.widget)
        self.setStyleSheet('background-color: #000000;')
Ejemplo n.º 8
0
    def __init__(self, parent=None):
        super(VideoUI, self).__init__(parent)
        self.__icon_dir = get_icon_dir()
        self.queue = None
        self.__source_files = list()
        self.__count = None
        self.__loop_status = None
        self.__icon_dir = get_icon_dir()
        self.resize(500, 300)
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(3, 3, 3, 3)
        main_layout.setSpacing(0)
        self.player = Phonon.MediaObject(self)
        self.player.setTransitionTime(0)
        self.audio_output = Phonon.AudioOutput(Phonon.MusicCategory, self)
        self.audio_output.setVolume(0.5)
        self.current_volume = 0.5
        self.__is_silence = False
        Phonon.createPath(self.player, self.audio_output)
        self.video_widget = VideoWidget(self)
        Phonon.createPath(self.player, self.video_widget)
        self.seek_slider = Phonon.SeekSlider(self.player, self)
        self.seek_slider.setStyleSheet(slider_style_sheet)
        self.seek_slider.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Fixed)
        self.volume_widget = VolumeWidget(self)
        self.volume_widget.volume_slider.setAudioOutput(self.audio_output)

        btn_layout = QHBoxLayout()
        btn_layout.setContentsMargins(0, 0, 0, 0)
        btn_layout.setSpacing(2)
        self.time_label = QLabel("00:00:00")
        # self.time_label.setStyleSheet("QLabel{background-color: transparent; color: #AAAAAA}")
        self.total_time_label = QLabel("00:00:00")
        # self.total_time_label.setStyleSheet("QLabel{background-color: transparent; color: #AAAAAA}")
        self.stop_btn = PlayerButton("stop", self)
        self.back_btn = PlayerButton("back", self)
        self.play_btn = PlayerButton("play", self)
        self.play_btn.setShortcut("space")
        self.next_btn = PlayerButton("next", self)
        self.full_screen_btn = PlayerButton("full_screen", self)
        self.volume_btn = PlayerButton("volume_on", self)
        self.loop_btn = PlayerButton("loop", self)
        btn_layout.addWidget(self.time_label)
        btn_layout.addWidget(self.seek_slider)
        btn_layout.addWidget(self.total_time_label)
        btn_layout.addWidget(self.stop_btn)
        btn_layout.addWidget(self.back_btn)
        btn_layout.addWidget(self.play_btn)
        btn_layout.addWidget(self.next_btn)
        btn_layout.addWidget(self.full_screen_btn)
        btn_layout.addWidget(self.loop_btn)
        btn_layout.addWidget(self.volume_btn)

        self.loop_menu = QMenu()
        self.single_loop_action = QAction("Single Loop Play", self)
        self.list_loop_action = QAction("List Loop Play", self)
        self.sequential_play_action = QAction("Sequential Play", self)
        self.loop_menu.addAction(self.sequential_play_action)
        self.loop_menu.addAction(self.single_loop_action)
        self.loop_menu.addAction(self.list_loop_action)
        self.loop_btn.setMenu(self.loop_menu)

        main_layout.addWidget(self.video_widget)
        main_layout.addLayout(btn_layout)
        self.set_signals()
        self.set_frame_ratio()
        self.loop_none()

        self.silence_icon = QIcon(
            os.path.join(self.__icon_dir, "volume_off.png"))
        self.no_silence_icon = QIcon(
            os.path.join(self.__icon_dir, "volume_on.png"))
Ejemplo n.º 9
0
    def buatSlider(self):
        self.posisi = Phonon.SeekSlider(self)
        self.volume = Phonon.VolumeSlider(self)

        self.volume.setAudioOutput(self.suara)
        self.posisi.setMediaObject(self.pemutar)
Ejemplo n.º 10
0
    def newwindows(self):
        import glob

        self.setWindowTitle('Media')
        action = QAction('text', self)
        self.actions = action.setStatusTip('check')
        self.setGeometry(100, 50, 1000, 1000)
        self.tool = QMenuBar(self)

        self.okay = self.tool.addMenu('okay')
        self.okay2 = self.tool.addMenu('okay')
        self.okay.addAction(action)

        self.setWindowIcon(
            QIcon('C:/Users/fish/Downloads/nice/icons8-sunday-50.png'))
        #'''''''\

        #self.layout = QVBoxLayout(self)
        #self.browser = QWebView(self)
        '''damnit = "http://www.google.com/"
        self.f***s = self.browser.load(QUrl(damnit))

        self.browser.move(500,100)
        self.browser.resize(500,500)'''
        dir = ''
        self.btnss = QPushButton('open file', self)
        self.btns2 = QPushButton('pause', self)
        self.btns3 = QPushButton('play', self)
        self.btns3.clicked.connect(self.played)
        self.btns2.clicked.connect(self.paused)
        self.btnss.move(100, 350)
        self.btns2.move(100, 400)
        self.btns3.move(100, 450)

        self.btnss.clicked.connect(self.fhile)

        path = self.filename
        print(self.filename)

        self.media = Phonon.MediaObject(self)
        self.video = Phonon.VideoWidget(self)
        self.video.setMinimumSize(400, 400)
        self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self)
        Phonon.createPath(self.media, self.audio)
        Phonon.createPath(self.media, self.video)
        self.media.setCurrentSource(Phonon.MediaSource(path))
        self.media.play()
        self.video.show()
        # -------------------------------------------
        self.btns4 = QPushButton('Full Screen', self)
        self.btns4.move(400, 0)
        self.btns4.clicked.connect(self.enlarged)
        # -------------------------------------------

        # -------------------------------------------
        self.slider = Phonon.VolumeSlider(self)
        self.slider.setAudioOutput(self.audio)
        self.slider.move(250, 50)
        self.slider.resize(250, 50)

        self.seekk = Phonon.SeekSlider(self)
        self.seekk.setMediaObject(self.media)
        self.seekk.move(200, 550)
        self.seekk.resize(350, 150)
        self.video.move(200, 200)
        # -------------------------------------------
        #self.view = QListView(self)
        #self.view.move(600,100)
        #self.view.resize(100,100)
        lists = glob.glob('C:/Users/fish/Downloads/*.WMV') + glob.glob(
            'C:/Users/fish/Downloads/*.mp4') + glob.glob(
                'C:/Users/fish/Downloads/*.flv')
        self.newview = QListWidget(self)
        self.newview.resize(300, 300)
        self.newview.move(600, 300)
        for item in lists:

            self.okay = QListWidgetItem('okay')
            self.okay.setData(Qt.UserRole, str(item))
            self.newview.addItem(self.okay)

            #self.newview.setValue(item)


# -------------------------------------------

        self.newview.clicked.connect(self.listfunc)
        #self.smodel = QStandardItemModel(self)

        # -------------------------------------------
        #self.setKey(QShortcut(Qt.Key_Escape, self))
        # self.act.setKey(QKeySequence('Alt+Enter'))
        #self.act.activated.connect(self.efullscreen)

        print(lists)
        #self.line = QTextEdit(self)
        #self.line.resize(25,25)
        #self.line.resize(25,25)
        #self.line.move(100,100)
        #self.line = QLineEdit(self)
        #self.line.resize(300,30)
        #self.line.move(600,70)
        # -------------------------------------------
        self.naved = QPushButton('browser', self)
        self.naved.clicked.connect(self.nav)

        # -------------------------------------------
        self.btned = QPushButton('Random Photo', self)
        self.btned.move(100, 300)
        self.btned.clicked.connect(self.check)
        # -------------------------------------------
        self.show()
        print(path)

        if path == None:
            self.lab = QLabel(self)
            paths = 'C:/Users/fish/Desktop/pexels-photo.jpg'
            self.img = QPixmap(paths)
            self.lab.setPixmap(paths)
            self.lab.move(200, 175)
            self.lab.resize(400, 400)
            self.lab.show()

        else:
            paths = ''

            self.lab.resize(10, 10)
            self.lab.move(10, 10)