def __init__(self, aPath, parent=None): super(VideoPlayer, self).__init__(parent) self.setAttribute( Qt.WA_NoSystemBackground, True ) self.colorDialog = None self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.mediaPlayer.setVolume(80) self.videoWidget = QVideoWidget(self) self.lbl = QLineEdit('00:00:00') self.lbl.setReadOnly(True) self.lbl.setEnabled(False) self.lbl.setFixedWidth(60) self.lbl.setUpdatesEnabled(True) self.lbl.setStyleSheet(stylesheet(self)) self.elbl = QLineEdit('00:00:00') self.elbl.setReadOnly(True) self.elbl.setEnabled(False) self.elbl.setFixedWidth(60) self.elbl.setUpdatesEnabled(True) self.elbl.setStyleSheet(stylesheet(self)) self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setFixedWidth(32) self.playButton.setStyleSheet("background-color: black") self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) self.positionSlider = QSlider(Qt.Horizontal, self) self.positionSlider.setStyleSheet (stylesheet(self)) self.positionSlider.setRange(0, 100) self.positionSlider.sliderMoved.connect(self.setPosition)
def __init__(self, parent=None): super(VideoPlayerWidget, self).__init__(parent) self.scene = QGraphicsScene(self) self.scene.setBackgroundBrush(QBrush(QColor(0, 0, 0, 255))) self.graphics_view = QGraphicsView(self.scene) self.graphics_view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.graphics_view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.graphics_view.setFrameStyle(0) self.graphics_view.setStyleSheet( "QGraphicsView {background: transparent; border: 3px; outline: none;}" ) self.video_item = QGraphicsVideoItem() self.scene.addItem(self.video_item) self.layout = QVBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.graphics_view) self.media_player = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.media_player.setVideoOutput(self.video_item) self.video_need_replay = False self.video_seek_durcation = 3000 # in milliseconds
def __init__(self): super().__init__() uic.loadUi('QTUI.ui', self) self.setWindowTitle('Игра «Угадай песню»') self.conn = sqlite3.connect('music_db.db') self.state_game = False self.played = [] self.used = set() self.score = 0 self.corr_answ = {'', ''} self.load_base.clicked.connect(self.load_own_musicdb) self.player = QMediaPlayer() self.timer = QTimer() self.selected_level = None self.answ_btn.clicked.connect(self.check_answ) self.easy_lvl_btn.clicked.connect(self.time_for_lvl) self.med_lvl_btn.clicked.connect(self.time_for_lvl) self.hard_lvl_btn.clicked.connect(self.time_for_lvl) self.load_own_sg.clicked.connect(self.load_own_song) self.start_btn.clicked.connect(self.start_game) self.stop_btn.clicked.connect(self.stop_game) self.volume_state.setValue(50) self.volume_state.valueChanged[int].connect(self.player.setVolume) self.btn_scorebrd.clicked.connect(self.show_scoreboard)
def __init__(self, parent): super().__init__(parent) self.parent_widget = parent self.setObjectName('Player') self.set_UI() # if parent == None: # self.setWindowFlags(Qt.FramelessWindowHint) '''用于播放音乐的对象''' self.music_player = QMediaPlayer(self) self.music_player.setVolume(70) self.music_player.setObjectName('MusicPlayer') ''' 歌曲列表 列表要显示在播放器之外的地方,因此不能把父窗口设置成self ''' self.play_list = PlayList(parent) '''播放进度''' self.millionsecond = 0 self.second = 0 self.lyric_panel = LyricPanel() self.set_connections()
def __init__(self, sqlConn): # Save sqlConnection for later self.sqlConnection = sqlConn # Call to superclass constructor QVideoWidget.__init__(self) #Create window and configure it self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, QSize(1280, 720), QApplication.desktop().availableGeometry())) self.setWindowTitle("BlueSky Airlines") self.setWindowIcon(QIcon('media/favicon.ico')) self.setWindowFlags(Qt.FramelessWindowHint) self.setStyleSheet('background-color: white;') #Setup the video player self.videoPlayer = QMediaPlayer() self.videoPlayer.setMedia( QMediaContent(QUrl('media/splashAnimation.avi'))) self.videoPlayer.setVideoOutput(self) self.videoPlayer.stateChanged.connect(self.handleVideoDone)
def __init__(self, QWidget_parent=None, Qt_WindowFlags_flags=0): QWidget.__init__(self, QWidget_parent) self.ui=Ui_VideoPlayerWidget() savecwd = os.getcwd() os.chdir('view/qt_ui') self.ui.setupUi(self) os.chdir(savecwd) self.duration=0 self.urls=list() self.default=-1 self.url=URL() self.saved_position=None self.media_player = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.media_player_widget = VideoWidget(self.ui.top_frame) self.ui.top_frame_layout.addWidget(self.media_player_widget) self.media_player.setVideoOutput(self.media_player_widget) self.media_player_widget.show() self.media_player.bufferStatusChanged.connect(lambda x:self.ui.buffer.setValue(x)) self.media_player.positionChanged.connect(self.positionChanged) self.media_player.durationChanged.connect(self.durationChanged) self.media_player.mediaStatusChanged.connect(self.media_status_changed) self.media_player.error.connect(self.handleError) # self.ui.buffer.hide() self.ui.bn_play.clicked.connect(self.media_player.play) self.ui.bn_pause.clicked.connect(self.media_player.pause) self.ui.bn_stop.clicked.connect(self.stop) self.ui.bn_mute.clicked.connect(self.media_player.setMuted) self.ui.progress.sliderMoved.connect(self.media_player.setPosition) self.ui.volume.valueChanged.connect(self.media_player.setVolume)
def __init__(self): super().__init__() self.player = QMediaPlayer() self.playlist = QMediaPlaylist() self.playlist.setPlaybackMode(QMediaPlaylist.Sequential) self.title = 'JPR Reader GUI version2' self.left = 50 self.top = 100 self.width = 1200 self.height = 800 self.fileReady = False self.tableRow = 5 self.tableCol = 15 self.row = 2 self.audiolist = [] self.configFile = ".//configurationFile.xlsx" self.dict = { 'num': None, 'partner': None, 'parcel': None, 'exception': None, 'box': None } self.initUI()
def __init__(self, name, bg, shoot, hit, score_up, swap, loose, win): """ Creates Soundpack name - soundpack name other params - non-absolute way to files """ self.name = name self.back = QMediaPlaylist() for sound in bg: url = QUrl.fromLocalFile(os.path.join(os.getcwd(), sound)) self.back.addMedia(QMediaContent(url)) self.back.setPlaybackMode(QMediaPlaylist.Loop) self.bg = QMediaPlayer() self.bg.setPlaylist(self.back) self.bg.setVolume(30) self.shoot = QSound(shoot) self.hit = QSound(hit) self.score_up = QSound(score_up) self.swap = QSound(swap) self.loose = QSound(loose) self.win = QSound(win)
def __init__(self, project=None, parent=None): super(VideoWindow, self).__init__(parent) self.project = project self.setWindowTitle("Video") self.mediaPlayer = QMediaPlayer() #None, QMediaPlayer.VideoSurface) self.last_position = 0 self.position_on_new_file = 0 self.duration = -1 self.waiting_for_file = False self.media_state_before_file_transition = self.mediaPlayer.state() self.video_time_offset = 0.0 self.play_icon = QIcon(play_icon_file) self.clock_icon = QIcon(clock_icon_file) self.pause_icon = QIcon(pause_icon_file) videoWidget = QVideoWidget() self.videoWidget = videoWidget self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setIcon(self.play_icon) self.playButton.clicked.connect(self.play) self.timeOffsetButton = QPushButton() self.timeOffsetButton.setIcon(self.clock_icon) self.timeOffsetButton.clicked.connect(self.setTimeOffset) self.positionSlider = QSlider(Qt.Horizontal) self.positionSlider.setRange(0, 0) self.positionSlider.sliderMoved.connect(self.setPosition) self.errorLabel = QLabel() self.errorLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum) # Create layouts to place inside widget controlLayout = QHBoxLayout() controlLayout.setContentsMargins(0, 0, 0, 0) controlLayout.addWidget(self.timeOffsetButton) controlLayout.addWidget(self.playButton) controlLayout.addWidget(self.positionSlider) layout = QVBoxLayout() layout.addWidget(videoWidget) layout.addLayout(controlLayout) layout.addWidget(self.errorLabel) # Hide error Label # Set widget to contain window contents self.setLayout(layout) self.mediaPlayer.setVideoOutput(videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.mediaStatusChanged.connect(self.mediaStatusChanged) self.mediaPlayer.error.connect(self.handleError) self.mediaPlayer.setNotifyInterval(40) # 25 fps if self.project is None: self.current_time_range = [0, 0] self.current_file = '' # self.mediaPlayer.setMedia(QMediaContent(QUrl.fromLocalFile(self.current_file))) # self.playButton.setEnabled(True) # self.mediaPlayer.play() elif self.project.current_animal.video_files: self.current_file = self.project.current_animal.video_files[0] self.current_time_range = [ self.project.current_animal.video_init_time[0], self.project.current_animal.video_init_time[0] + self.project.current_animal.video_duration[0] ] self.mediaPlayer.setMedia( QMediaContent(QUrl.fromLocalFile(self.current_file))) self.playButton.setEnabled(True) else: self.current_file = '' self.current_time_range = [0, 0]
def initPlayer(self): """初始化播放器""" self.player = QMediaPlayer(self) # 创建播放器 self.playList = QMediaPlaylist(self.player) # 播放列表 self.playList.setPlaybackMode(QMediaPlaylist.CurrentItemInLoop) # 播放模式 """
def init_ui(self): self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.mediaPlayer.setMedia( QMediaContent(QUrl.fromLocalFile(self.data.src))) videowidget = QVideoWidget() self.playBtn = QPushButton() self.playBtn.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playBtn.clicked.connect(self.play_video) self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, 0) self.slider.sliderMoved.connect(self.set_position) self.show_full_screen_button = QPushButton('Full Screen') self.show_full_screen_button.clicked.connect(self.full_screen_switch) self.movie_info_button = QPushButton('Movie') self.movie_info_button.clicked.connect(self.movie_info) if self.data.series: self.series_info_button = QPushButton('Series') self.series_info_button.clicked.connect(self.series_info) self.mute = QPushButton() self.mute.setIcon(self.style().standardIcon(QStyle.SP_MediaVolume)) self.mute.clicked.connect(self.mute_clicked) self.label = QLabel() self.label.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) hboxLayout = QHBoxLayout() hboxLayout.setContentsMargins(20, 20, 20, 10) hboxLayout.addWidget(self.playBtn) hboxLayout.addWidget(self.slider) hboxLayout.addWidget(self.mute) hboxLayout.addWidget(self.movie_info_button) if self.data.series: hboxLayout.addWidget(self.series_info_button) hboxLayout.addWidget(self.show_full_screen_button) self.set_player() self.hboxLayout2 = QHBoxLayout() self.hboxLayout2.setContentsMargins(10, 10, 10, 10) self.buttons_stars = QButtonGroup() self.buttons_series = QButtonGroup() self.add_grup_movies_buttons() # create vbox layout vboxLayout = QVBoxLayout() vboxLayout.addWidget(videowidget) vboxLayout.addLayout(hboxLayout) vboxLayout.addLayout(self.hboxLayout2) vboxLayout.addWidget(self.label) self.setLayout(vboxLayout) self.mediaPlayer.setVideoOutput(videowidget) # media player signals self.mediaPlayer.stateChanged.connect(self.mediastate_changed) self.mediaPlayer.positionChanged.connect(self.position_changed) self.mediaPlayer.durationChanged.connect(self.duration_changed)
def __init__(self, playlist, parent=None): super(Player, self).__init__(parent) self.colorDialog = None self.trackInfo = "" self.statusInfo = "" self.duration = 0 self.player = QMediaPlayer() self.playlist = QMediaPlaylist() self.player.setPlaylist(self.playlist) self.player.durationChanged.connect(self.durationChanged) self.player.positionChanged.connect(self.positionChanged) self.player.metaDataChanged.connect(self.metaDataChanged) self.playlist.currentIndexChanged.connect(self.playlistPositionChanged) self.player.mediaStatusChanged.connect(self.statusChanged) self.player.bufferStatusChanged.connect(self.bufferingProgress) self.player.videoAvailableChanged.connect(self.videoAvailableChanged) self.player.error.connect(self.displayErrorMessage) self.videoWidget = VideoWidget() self.player.setVideoOutput(self.videoWidget) self.playlistModel = PlaylistModel() self.playlistModel.setPlaylist(self.playlist) self.playlistView = QListView() self.playlistView.setModel(self.playlistModel) self.playlistView.setCurrentIndex( self.playlistModel.index(self.playlist.currentIndex(), 0)) self.playlistView.activated.connect(self.jump) self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, self.player.duration() / 1000) self.labelDuration = QLabel() self.slider.sliderMoved.connect(self.seek) # self.labelHistogram = QLabel() # self.labelHistogram.setText("Histogram:") # self.histogram = HistogramWidget() # histogramLayout = QHBoxLayout() # histogramLayout.addWidget(self.labelHistogram) # histogramLayout.addWidget(self.histogram, 1) self.probe = QVideoProbe() # self.probe.videoFrameProbed.connect(self.histogram.processFrame) self.probe.setSource(self.player) openButton = QPushButton("打开", clicked=self.open) controls = PlayerControls() controls.setState(self.player.state()) controls.setVolume(self.player.volume()) controls.setMuted(controls.isMuted()) controls.play.connect(self.player.play) controls.pause.connect(self.player.pause) controls.stop.connect(self.player.stop) controls.next.connect(self.playlist.next) controls.previous.connect(self.previousClicked) controls.changeVolume.connect(self.player.setVolume) controls.changeMuting.connect(self.player.setMuted) controls.changeRate.connect(self.player.setPlaybackRate) controls.stop.connect(self.videoWidget.update) self.player.stateChanged.connect(controls.setState) self.player.volumeChanged.connect(controls.setVolume) self.player.mutedChanged.connect(controls.setMuted) self.fullScreenButton = QPushButton("全屏") self.fullScreenButton.setCheckable(True) self.colorButton = QPushButton("颜色选项") self.colorButton.setEnabled(False) self.colorButton.clicked.connect(self.showColorDialog) displayLayout = QHBoxLayout() displayLayout.addWidget(self.videoWidget, 2) displayLayout.addWidget(self.playlistView) controlLayout = QHBoxLayout() controlLayout.setContentsMargins(0, 0, 0, 0) controlLayout.addWidget(openButton) controlLayout.addStretch(1) controlLayout.addWidget(controls) controlLayout.addStretch(1) controlLayout.addWidget(self.fullScreenButton) controlLayout.addWidget(self.colorButton) layout = QVBoxLayout() layout.addLayout(displayLayout) hLayout = QHBoxLayout() hLayout.addWidget(self.slider) hLayout.addWidget(self.labelDuration) layout.addLayout(hLayout) layout.addLayout(controlLayout) # layout.addLayout(histogramLayout) self.setLayout(layout) if not self.player.isAvailable(): QMessageBox.warning( self, "Service not available", "The QMediaPlayer object does not have a valid service.\n" "Please check the media service plugins are installed.") controls.setEnabled(False) self.playlistView.setEnabled(False) openButton.setEnabled(False) self.colorButton.setEnabled(False) self.fullScreenButton.setEnabled(False) self.metaDataChanged() self.addToPlaylist(playlist)
def __init__(self, parent=None): # 构造函数 super(videoPlayer, self).__init__(parent=parent) # 类的继承 self.mainwindow = parent self.length = 0 # 视频总时长 self.position = 0 # 视频当前时长 self.count = 0 self.player_status = -1 # 设置窗口 self.setGeometry(300, 50, 800, 600) #大小,与桌面放置位置 # self.setWindowIcon(QIcon(':/images/video_player_icon.png')) # 程序图标 # self.setWindowTitle(titleName) # 窗口名称 # self.setWindowFlags(Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint) # 设置窗口背景 self.palette = QPalette() self.palette.setColor(QPalette.Background, Qt.black) self.setPalette(self.palette) self.now_position = QLabel("/ 00:00") # 目前时间进度 self.all_duration = QLabel('00:00') # 总的时间进度 self.all_duration.setStyleSheet('''QLabel{color:#000000}''') self.now_position.setStyleSheet('''QLabel{color:#000000}''') #视频插件 self.video_widget = QVideoWidget(self) self.video_widget.setGeometry(QRect(0, 0, 1200, 700)) #大小,与桌面放置位置 #self.video_widget.resize(1200, 700) # 设置插件宽度与高度 #self.video_widget.move(0, 30) # 设置插件放置位置 self.video_palette = QPalette() self.video_palette.setColor(QPalette.Background, Qt.black) # 设置播放器背景 self.video_widget.setPalette(self.video_palette) video_widget_color = "background-color:#000000" self.video_widget.setStyleSheet(video_widget_color) #布局容器 self.verticalLayout = QVBoxLayout() self.verticalLayout.setSpacing(0) #self.verticalLayout.setContentsMargins(0, 5, 0, 10) self.layout = QHBoxLayout() self.layout.setSpacing(15) # 各个插件的间距 # 设置播放器 self.player = QMediaPlayer(self) self.player.setVideoOutput(self.video_widget) #设置播放按钮事件 self.player.durationChanged.connect(self.get_duration_func) # self.player.positionChanged.connect(self.progress) # 媒体播放时发出信号 self.player.mediaStatusChanged.connect(self.playerStatusChanged) self.player.error.connect(self.player_error) # 播放按钮 self.play_btn = QPushButton(self) self.play_btn.setIcon(QIcon(':/images/play_btn_icon.png')) # 设置按钮图标,下同 self.play_btn.setIconSize(QSize(35, 35)) self.play_btn.setStyleSheet( '''QPushButton{border:none;}QPushButton:hover{border:none;border-radius:35px;}''' ) self.play_btn.setCursor(QCursor(Qt.PointingHandCursor)) self.play_btn.setToolTip("播放") self.play_btn.setFlat(True) #self.play_btn.hide() #isHidden() #判定控件是否隐藏 #isVisible() 判定控件是否显示 self.play_btn.clicked.connect(self.start_button) #音量条 self.volume_slider = QSlider(Qt.Horizontal) # 声音设置 self.volume_slider.setMinimum(0) # 音量0到100 self.volume_slider.setMaximum(100) self.volume_slider.valueChanged.connect(self.volumes_change) self.volume_slider.setStyleSheet('''QSlider{} QSlider::sub-page:horizontal:disabled{background: #00009C; border-color: #999; } QSlider::add-page:horizontal:disabled{background: #eee; border-color: #999; } QSlider::handle:horizontal:disabled{background: #eee; border: 1px solid #aaa; border-radius: 4px; } QSlider::add-page:horizontal{background: #575757; border: 0px solid #777; height: 10px;border-radius: 2px; } QSlider::handle:horizontal:hover{background:qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0.6 #2A8BDA, stop:0.778409 rgba(255, 255, 255, 255)); width: 11px; margin-top: -3px; margin-bottom: -3px; border-radius: 5px; } QSlider::sub-page:horizontal{background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4); background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,stop: 0 #5DCCFF, stop: 1 #1874CD); border: 1px solid #4A708B; height: 10px; border-radius: 2px; } QSlider::groove:horizontal{border: 1px solid #4A708B; background: #C0C0C0; height: 5px; border-radius: 1px; padding-left:-1px; padding-right:-1px;} QSlider::handle:horizontal{background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0.6 #45ADED, stop:0.778409 rgba(255, 255, 255, 255)); width: 11px; margin-top: -3px; margin-bottom: -3px; border-radius: 5px; }''' ) #视频播放进度条 self.video_slider = QSlider(Qt.Horizontal, self) # 视频进度拖拖动 self.video_slider.setMinimum(0) # 视频进度0到100% #self.video_slider.setMaximum(100) self.video_slider.setSingleStep(1) self.video_slider.setGeometry(QRect(0, 0, 200, 10)) self.video_slider.sliderReleased.connect(self.video_silder_released) self.video_slider.sliderPressed.connect(self.video_silder_pressed) self.video_slider.setStyleSheet('''QSlider{} QSlider::sub-page:horizontal:disabled{background: #00009C; border-color: #999; } QSlider::add-page:horizontal:disabled{background: #eee; border-color: #999; } QSlider::handle:horizontal:disabled{background: #eee; border: 1px solid #aaa; border-radius: 4px; } QSlider::add-page:horizontal{background: #575757; border: 0px solid #777; height: 10px;border-radius: 2px; } QSlider::handle:horizontal:hover{background:qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0.6 #2A8BDA, stop:0.778409 rgba(255, 255, 255, 255)); width: 11px; margin-top: -3px; margin-bottom: -3px; border-radius: 5px; } QSlider::sub-page:horizontal{background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4); background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,stop: 0 #5DCCFF, stop: 1 #1874CD); border: 1px solid #4A708B; height: 10px; border-radius: 2px; } QSlider::groove:horizontal{border: 1px solid #4A708B; background: #C0C0C0; height: 5px; border-radius: 1px; padding-left:-1px; padding-right:-1px;} QSlider::handle:horizontal{background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0.6 #45ADED, stop:0.778409 rgba(255, 255, 255, 255)); width: 11px; margin-top: -3px; margin-bottom: -3px; border-radius: 5px; }''' ) #静音按钮 self.mute_button = QPushButton('') self.mute_button.clicked.connect(self.mute) self.mute_button.setIconSize(QSize(30, 30)) self.mute_button.setStyleSheet( '''QPushButton{border:none;}QPushButton:hover{border:none;}''') self.mute_button.setCursor(QCursor(Qt.PointingHandCursor)) self.mute_button.setToolTip("播放") self.mute_button.setFlat(True) self.mute_button.setIcon(QIcon(':/images/sound_btn_icon.png')) #暂停按钮 self.pause_btn = QPushButton('') self.pause_btn.setIcon(QIcon(':/images/stop_btn_icon.png')) self.pause_btn.clicked.connect(self.stop_button) self.pause_btn.setIconSize(QSize(35, 35)) self.pause_btn.setStyleSheet( '''QPushButton{border:none;}QPushButton:hover{border:none;}''') self.pause_btn.setCursor(QCursor(Qt.PointingHandCursor)) self.pause_btn.setToolTip("播放") self.pause_btn.setFlat(True) self.pause_btn.hide() #音量值和音量显示标签 self.volume_value = QLabel() self.volume_value.setText(' ' * 5) self.volume_value.setStyleSheet('''QLabel{color:#000000;}''') self.volume_t = QLabel() self.volume_t.setStyleSheet('''QLabel{color:#000000;}''') #视频文件打开按钮 self.open_btn = QPushButton('Open') self.open_btn.clicked.connect(self.getfile) #全屏按钮 self.screen_btn = QPushButton('') self.screen_btn.setIcon( QIcon(QPixmap(':/images/fullsrceen_btn_icon.png'))) self.screen_btn.setIconSize(QSize(38, 38)) self.screen_btn.setStyleSheet( '''QPushButton{border:none;}QPushButton:hover{border:1px solid #F3F3F5;border-radius:35px;}''' ) self.screen_btn.setCursor(QCursor(Qt.PointingHandCursor)) self.screen_btn.setToolTip("播放") self.screen_btn.setFlat(True) self.screen_btn.clicked.connect(self.fullscreen) #添加按钮组件 self.verticalLayout.addStretch() self.layout.addWidget(self.play_btn, 0, Qt.AlignCenter | Qt.AlignVCenter) self.layout.addWidget(self.pause_btn, 0, Qt.AlignCenter | Qt.AlignVCenter) # 插件,与前一个模块的距离,位置 self.layout.addWidget(self.all_duration, 0, Qt.AlignCenter | Qt.AlignVCenter) self.layout.addWidget(self.now_position, 0, Qt.AlignCenter | Qt.AlignVCenter) self.layout.addWidget(self.video_slider, 15, Qt.AlignVCenter | Qt.AlignVCenter) self.layout.addWidget(self.mute_button, 0, Qt.AlignCenter | Qt.AlignVCenter) self.layout.addWidget(self.volume_slider, 0, Qt.AlignCenter | Qt.AlignVCenter) self.layout.addWidget(self.volume_value, 0, Qt.AlignCenter | Qt.AlignVCenter) #self.layout.addWidget(self.screen_btn) #self.layout.addWidget(self.open_btn) self.verticalLayout.addLayout(self.layout) #self.verticalLayout.addLayout(self.layout) self.setLayout(self.verticalLayout)
def __init__(self, aPath, parent=None): super(VideoPlayer, self).__init__(parent) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAcceptDrops(True) self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.StreamPlayback) self.mediaPlayer.mediaStatusChanged.connect(self.printMediaData) self.mediaPlayer.setVolume(80) self.videoWidget = QVideoWidget(self) self.lbl = QLineEdit('00:00:00') self.lbl.setReadOnly(True) self.lbl.setFixedWidth(70) self.lbl.setUpdatesEnabled(True) self.lbl.setStyleSheet(stylesheet(self)) self.elbl = QLineEdit('00:00:00') self.elbl.setReadOnly(True) self.elbl.setFixedWidth(70) self.elbl.setUpdatesEnabled(True) self.elbl.setStyleSheet(stylesheet(self)) self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setFixedWidth(32) self.playButton.setStyleSheet("background-color: black") self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) self.positionSlider = QSlider(Qt.Horizontal, self) self.positionSlider.setStyleSheet(stylesheet(self)) self.positionSlider.setRange(0, 100) self.positionSlider.sliderMoved.connect(self.setPosition) self.positionSlider.sliderMoved.connect(self.handleLabel) self.positionSlider.setSingleStep(2) self.positionSlider.setPageStep(20) self.positionSlider.setAttribute(Qt.WA_TranslucentBackground, True) self.clip = QApplication.clipboard() self.process = QProcess(self) self.process.readyRead.connect(self.dataReady) # self.process.started.connect(lambda: print("grabbing YouTube URL")) self.process.finished.connect(self.playFromURL) self.myurl = "" controlLayout = QHBoxLayout() controlLayout.setContentsMargins(5, 0, 5, 0) controlLayout.addWidget(self.playButton) controlLayout.addWidget(self.lbl) controlLayout.addWidget(self.positionSlider) controlLayout.addWidget(self.elbl) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.videoWidget) layout.addLayout(controlLayout) self.setLayout(layout) self.myinfo = "©2016\nAxel Schneider\n\nMouse Wheel = Zoom\nUP = Volume Up\nDOWN = Volume Down\n" + \ "LEFT = < 1 Minute\nRIGHT = > 1 Minute\n" + \ "SHIFT+LEFT = < 10 Minutes\nSHIFT+RIGHT = > 10 Minutes" self.widescreen = True #### shortcuts #### self.shortcut = QShortcut(QKeySequence("q"), self) self.shortcut.activated.connect(self.handleQuit) self.shortcut = QShortcut(QKeySequence("u"), self) self.shortcut.activated.connect(self.playFromURL) self.shortcut = QShortcut(QKeySequence("y"), self) self.shortcut.activated.connect(self.getYTUrl) self.shortcut = QShortcut(QKeySequence("o"), self) self.shortcut.activated.connect(self.openFile) self.shortcut = QShortcut(QKeySequence(" "), self) self.shortcut.activated.connect(self.play) self.shortcut = QShortcut(QKeySequence("f"), self) self.shortcut.activated.connect(self.handleFullscreen) self.shortcut = QShortcut(QKeySequence("i"), self) self.shortcut.activated.connect(self.handleInfo) self.shortcut = QShortcut(QKeySequence("s"), self) self.shortcut.activated.connect(self.toggleSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Right), self) self.shortcut.activated.connect(self.forwardSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Left), self) self.shortcut.activated.connect(self.backSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Up), self) self.shortcut.activated.connect(self.volumeUp) self.shortcut = QShortcut(QKeySequence(Qt.Key_Down), self) self.shortcut.activated.connect(self.volumeDown) self.shortcut = QShortcut( QKeySequence(Qt.ShiftModifier + Qt.Key_Right), self) self.shortcut.activated.connect(self.forwardSlider10) self.shortcut = QShortcut(QKeySequence(Qt.ShiftModifier + Qt.Key_Left), self) self.shortcut.activated.connect(self.backSlider10) self.mediaPlayer.setVideoOutput(self.videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.positionChanged.connect(self.handleLabel) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError) print("QT5 Player started") self.suspend_screensaver() # msg = QMessageBox.information(self, "Qt5Player", "press o to open file") self.loadFilm("/home/brian/Dokumente/Qt5PlayerIntro.m4v")
def __init__(self, parent, daze_data, current_item): super().__init__(parent) self.daze_data = daze_data self.media_player = QMediaPlayer(self) self.media_player.stateChanged.connect(self.media_state_changed) self.media_player.positionChanged.connect(self.position_changed) self.vbox = QVBoxLayout() self.hbox = QHBoxLayout() self.hbox2 = QHBoxLayout() self.setGeometry(200, 200, 550, 150) self.current_item = current_item self.audio_name = QLabel(current_item.data()) self.save_button = QPushButton('Save', self) self.save_button.clicked.connect(self.save_clicked) self.close_button = QPushButton('Close', self) self.close_button.clicked.connect(self.close_clicked) self.play_button = QPushButton(self) self.play_button.setIcon(self.style().standardIcon( QStyle.SP_MediaPlay)) self.play_button.clicked.connect(self.play_audio) self.play_button.setEnabled(True) media_path = (self.daze_data.get('Playlist').get( self.current_item.data()).get('filename')) audio = mp3.MP3(media_path) self.audio_length = audio.info.length self.qrangeslider = QRangeSlider(parent=self) self.qrangeslider.setFixedHeight(50) self.qrangeslider.setMin(0) self.qrangeslider.setMax(round(self.audio_length)) self.max_val = round(self.audio_length) self.min_val = round(0) self.qrangeslider.setRange(0, round(self.audio_length)) self.qrangeslider.setBackgroundStyle( 'background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #222, stop:1 #333);' ) self.qrangeslider.setSpanStyle( 'background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #282, stop:1 #393);' ) self.qrangeslider.handle.setTextColor(0) self.qrangeslider.start_changed.connect(self.start_changed) self.qrangeslider.end_changed.connect(self.end_changed) self.end_time = str( datetime.timedelta(seconds=round(self.audio_length))) self.length_time = self.end_time self.start_time = str(datetime.timedelta(seconds=round(0))) self.current_time = self.start_time self.running_time = QLabel('{}/{}'.format(self.current_time, self.length_time)) self.vbox.addWidget(self.audio_name) self.hbox2.addWidget(self.play_button) self.hbox2.addWidget(self.qrangeslider) self.hbox2.addWidget(self.running_time) self.hbox.addWidget(self.close_button) self.hbox.addWidget(self.save_button) self.vbox.addLayout(self.hbox2) self.vbox.addLayout(self.hbox) self.setLayout(self.vbox) self.audio_filename = (self.daze_data.get('Playlist').get( current_item.data()).get('filename')) # possibly set slider to audio length here audio_file = QUrl.fromLocalFile(self.audio_filename) audio_content = QMediaContent(audio_file) self.media_player.setMedia(audio_content)
from datetime import datetime import win32com.client from apscheduler.schedulers.qt import QtScheduler from decouple import config from PyQt5.QtCore import QUrl from PyQt5.QtGui import QIcon from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer from PyQt5.QtWidgets import QAction, QApplication, QMenu, QSystemTrayIcon GROUP_FOLDER = config("GROUP_FOLDER") TARGET_FOLDER = config("TARGET_FOLDER") AUDIO = config("AUDIO") INTERVAL = 5 mediaPlayer = QMediaPlayer(None, flags=QMediaPlayer.VideoSurface) mediaPlayer.setMedia(QMediaContent(QUrl.fromLocalFile(AUDIO))) logging.basicConfig( filename='running.log', format="%(asctime)s - %(name)s - %(levelname)s - %(funcName)s:%(lineno)d - %(message)s" ) logger = logging.getLogger(__name__) def checkUnreadEmail(folder, target, player, logger): logger.warning("Start checking email") try: outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") japanFolder = outlook.folders(folder)
def __init__(self, parent=None): # Super (whatever that means) super(VideoPlayer, self).__init__() # Initialize self.setGeometry(400, 100, 1280, 960) self.setWindowTitle('ProjecTosh by Trent Baker (c) 2019') # Set window background color self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), QColor(53, 64, 38)) self.setPalette(p) # UI and widgets and such # Video widget self.video = QVideoWidget() #self.video.resize(300, 300) #self.video.move(0, 0) # Media Playlist self.playlist = QMediaPlaylist() self.playlist.addMedia(QMediaContent(QUrl.fromLocalFile("video/video.avi"))) # https://www.nps.gov/grca/learn/photosmultimedia/b-roll_hd07.htm (default is public domain b-roll video) self.playlist.setPlaybackMode(QMediaPlaylist.Loop) self.playlist.setCurrentIndex(0) # Video player widget self.player = QMediaPlayer() self.player.setPlaylist(self.playlist) self.player.setVideoOutput(self.video) #self.player.setMedia() self.player.play() # Label widgets fnt = QtGui.QFont('Impact', 20) h = announcements.announcements[1][0] b = announcements.announcements[1][1] # Announcements body self.lbAnnounce = QLabel() self.lbAnnounce.setText(h+'\n\n'+b) self.lbAnnounce.setFont(fnt) self.lbAnnounce.setAlignment(Qt.AlignTop) self.lbAnnounce.setWordWrap(True) self.lbAnnounce.setMaximumSize(600, 400) self.lbAnnounce.setStyleSheet("color: rgb(250, 241, 205);") # Current day self.lbDay = QLabel() self.lbDay.setText("it's day 1 lol") self.lbDay.setAlignment(Qt.AlignCenter) # Grad events self.lbGrad = QLabel() self.lbGrad.setText('upcoming grad event:\nsled') self.lbGrad.setAlignment(Qt.AlignCenter) # Timer for cycling announcement i = 1 j = 1 # Called when timer hits limit def handler(): nonlocal h, b, i, j # Here i is the 'x' index of the 2D announcements.announcements array, and j is the 'y' j += 1 # Print attempt begin print("Trying announcement at index "+str(i)) # Cycle fake for loop if j >= len(announcements.announcements[i]): j = 1 i += 1 if i >= len(announcements.announcements): i = 1 # Try until get announcement error = True while error: try: h = announcements.announcements[i][0] b = announcements.announcements[i][j] # At present this is only listing the first non-title item in the annoucement lists ann = h + '\n\n' + b print("Successfully updated announcement from index "+str(i)) error = False except: print("Error when converting announcement at index "+str(i)+", skipping") i += 1 # Update announcement text self.lbAnnounce.setText(ann) self.timer = QtCore.QTimer() self.timer.timeout.connect(handler) self.timer.start(2000) # Do the layout move to do the layout move self.grid = QGridLayout() w = 4 h = 3 wl = 2 wr = w-wl ht = 1 hb = h-ht self.grid.addWidget(self.lbDay, 0, 0, ht, wl) self.grid.addWidget(self.lbGrad, ht, 0, hb, wl) self.grid.addWidget(self.video, 0, wl, ht, wr) self.grid.addWidget(self.lbAnnounce, ht, wl, hb, wr) self.setLayout(self.grid)
def __init__(self, parent=None): super(VideoWindow, self).__init__(parent) self.setWindowTitle( "PyQt Video Player Widget Example - pythonprogramminglanguage.com") self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) videoWidget = QVideoWidget() self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) self.positionSlider = QSlider(Qt.Horizontal) self.positionSlider.setRange(0, 0) self.positionSlider.sliderMoved.connect(self.setPosition) self.errorLabel = QLabel() self.errorLabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) # Create new action openAction = QAction(QIcon('open.png'), '&Open', self) openAction.setShortcut('Ctrl+O') openAction.setStatusTip('Open movie') openAction.triggered.connect(self.openFile) # Create exit action exitAction = QAction(QIcon('exit.png'), '&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(self.exitCall) # Create menu bar and add action menuBar = self.menuBar() fileMenu = menuBar.addMenu('&File') #fileMenu.addAction(newAction) fileMenu.addAction(openAction) fileMenu.addAction(exitAction) # Create a widget for window contents wid = QWidget(self) self.setCentralWidget(wid) # Create layouts to place inside widget controlLayout = QHBoxLayout() controlLayout.setContentsMargins(0, 0, 0, 0) controlLayout.addWidget(self.playButton) controlLayout.addWidget(self.positionSlider) layout = QVBoxLayout() layout.addWidget(videoWidget) layout.addLayout(controlLayout) layout.addWidget(self.errorLabel) # Set widget to contain window contents wid.setLayout(layout) self.mediaPlayer.setVideoOutput(videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError)
def __init__(self): super(UIMainWindow, self).__init__() uic.loadUi('ui.ui', self) pg.setConfigOptions(antialias=True) self.plots = [] self.datalines = [] self.samples = [np.array([]), np.array([]), np.array([])] # origin, test1, test2 self.time = 0 self.fft_samples = [0, 0, 0] self.freqs_ = 0 self.gain_values = np.zeros(20).reshape((2, 10)) self.pens = [ pg.mkPen('r'), pg.mkPen('w'), pg.mkPen('y'), pg.mkPen('g'), pg.mkPen('m'), pg.mkPen('w') ] for i in range(3): plot1 = self.gView.addPlot(title="Time Domain") plot2 = self.gView.addPlot(title="Frequency Domain") self.gView.nextRow() self.plots.append(plot1) self.plots.append(plot2) for i in range(6): self.datalines.append(self.plots[i].plot(pen=self.pens[i])) self.linear_regions = [] self.NUM_BANDS = 10 self.line_position = 0 # origin , test1, test2 self.mediaPlayers = [QMediaPlayer(), QMediaPlayer(), QMediaPlayer()] self.timer = QtCore.QTimer() # for regions on graph self.timer.setInterval(180) self.timer.timeout.connect(self.removeRegion) self.actionNew_Window.triggered.connect(lambda: self.new_win()) self.timer1 = QtCore.QTimer() # for control the playing of audio self.timer1.setInterval(100) self.timer1.timeout.connect(self.update_postion) self.comb_box_current_index = [0, 0] # UI self.freq_bands = [ self.freq1, self.freq2, self.freq3, self.freq4, self.freq5, self.freq6, self.freq7, self.freq8, self.freq9, self.freq10 ] self.gains = [ self.gain1, self.gain2, self.gain3, self.gain4, self.gain5, self.gain6, self.gain7, self.gain8, self.gain9, self.gain10 ] self.sliders = [ self.slider1, self.slider2, self.slider3, self.slider4, self.slider5, self.slider6, self.slider7, self.slider8, self.slider9, self.slider10 ] self.tests = [self.test1, self.test2] self.test_is_modified = [0, 0] self.playline = self.playGraph.plot() self.pen = pg.mkPen(color='r', width=3) self.playGraph.setYRange(min=-2, max=2) self.playGraph.showAxis('bottom', False) self.playGraph.plotItem.autoBtn = None self.playGraph.showAxis('left', False) self.min_gain = -30 # dB self.max_gain = 30 # dB self.disable_some_uis() # connections self.add_file_btn.clicked.connect(self.add_file) self.play_btn.clicked.connect(self.play_audio) self.pause_btn.clicked.connect(self.pause_audio) self.orgin_radio.clicked.connect(self.stop_play) self.test_radio.clicked.connect(self.stop_play) self.show_dif_btn.clicked.connect(self.show_popup) self.pushButton.clicked.connect(self.show_popup2) self.save_btn.clicked.connect(self.save) self.reset_btn.clicked.connect(self.reset_sliders) for i in range(2): self.connect_tests(i) for i in range(self.NUM_BANDS): self.connect_sliders(i) self.is_playing = False
def otherPages(self): self.mediaPlayer4 = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.playButton4 = QPushButton("Play") self.playButton4.setEnabled(True) #default is on False, will not play video #How the button looks self.playButton4.clicked.connect( self.play4) #when clicked, should play self.positionSlider4 = QSlider(Qt.Horizontal) #the video slider self.positionSlider4.setRange(0, 0) #setting the range of the slider self.positionSlider4.sliderMoved.connect(self.setPosition4) self.errorLabel4 = QLabel() self.errorLabel4.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) # Create a widget for window contents # Create layouts to place inside widget self.videoWidget4 = QVideoWidget() self.controlLayout4 = QHBoxLayout() self.controlLayout4.setContentsMargins(0, 0, 0, 0) self.controlLayout4.addWidget(self.playButton4) self.controlLayout4.addWidget(self.positionSlider4) self.layout4 = QVBoxLayout() self.layout4.addWidget(self.videoWidget4) self.layout4.addLayout(self.controlLayout4) self.layout4.addWidget(self.errorLabel4) # Set widget to contain window contents self.Video_widget4 = QWidget() self.Video_widget4.setLayout(self.layout4) self.mediaPlayer4.setVideoOutput(self.videoWidget4) self.mediaPlayer4.stateChanged.connect(self.mediaStateChanged4) self.mediaPlayer4.positionChanged.connect(self.positionChanged4) self.mediaPlayer4.durationChanged.connect(self.durationChanged4) self.mediaPlayer4.error.connect(self.handleError4) self.loaded4 = 0 self.l14 = QLabel() self.l24 = QLabel() self.l34 = QLabel() self.l44 = QLabel() self.tab1Lay4 = QVBoxLayout() for i, j in zip([1, 2, 3, 4], [self.l14, self.l24, self.l34, self.l44]): j.setPixmap(QPixmap("media/Iodination-" + str(i) + ".jpg")) j.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) j.setAlignment(Qt.AlignCenter) self.tab1Lay4.addWidget(j) self.scrollWidget4 = QWidget() self.scrollWidget4.setLayout(self.tab1Lay4) self.scrollAr4 = QScrollArea() self.scrollAr4.setWidget(self.scrollWidget4) self.tab1Lay24 = QVBoxLayout() self.tab1Lay24.addWidget(self.scrollAr4) self.tab14.setLayout(self.tab1Lay24) self.mode = False self.tab3Lay4 = QVBoxLayout() self.tab3Lay4.addWidget(self.Video_widget4) self.tab34.setLayout(self.tab3Lay4) '''
def __init__(self, aPath, parent=None): super(VideoPlayer, self).__init__(parent) #self.setAttribute(Qt.WA_NoSystemBackground, True) self.colorDialog = None self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.mediaPlayer.setVolume(80) self.videoWidget = QVideoWidget(self) self.lbl = QLineEdit('00:00:00') self.lbl.setReadOnly(True) self.lbl.setEnabled(False) self.lbl.setFixedWidth(60) self.lbl.setUpdatesEnabled(True) #self.lbl.setStyleSheet(stylesheet(self)) self.elbl = QLineEdit('00:00:00') self.elbl.setReadOnly(True) self.elbl.setEnabled(False) self.elbl.setFixedWidth(60) self.elbl.setUpdatesEnabled(True) #self.elbl.setStyleSheet(stylesheet(self)) self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setFixedWidth(32) #self.playButton.setStyleSheet("background-color: black") self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) ### pointA button self.apointButton = QPushButton() self.apointButton.setEnabled(False) self.apointButton.setFixedWidth(32) #self.apointButton.setStyleSheet("background-color: black") self.apointButton.setIcon(self.style().standardIcon( QStyle.SP_MediaSeekForward)) self.apointButton.clicked.connect(self.setPointA) ### pointB button self.bpointButton = QPushButton() self.bpointButton.setEnabled(False) self.bpointButton.setFixedWidth(32) #self.bpointButton.setStyleSheet("background-color: black") self.bpointButton.setIcon(self.style().standardIcon( QStyle.SP_MediaSeekBackward)) self.bpointButton.clicked.connect(self.setPointB) ### cut button self.cutButton = QPushButton() self.cutButton.setEnabled(False) self.cutButton.setFixedWidth(32) self.cutButton.setIcon(self.style().standardIcon( QStyle.SP_DriveFDIcon)) self.cutButton.clicked.connect(self.cut) self.positionSlider = QSlider(Qt.Horizontal, self) self.positionSlider.setStyleSheet(stylesheet(self)) self.positionSlider.setRange(0, 100) self.positionSlider.sliderMoved.connect(self.setPosition) self.positionSlider.sliderMoved.connect(self.handle_label) self.positionSlider.setSingleStep(2) self.positionSlider.setPageStep(20) #self.positionSlider.setAttribute(Qt.WA_NoSystemBackground, True) controlLayout = QHBoxLayout() controlLayout.setContentsMargins(5, 0, 5, 0) controlLayout.addWidget(self.playButton) controlLayout.addWidget(self.apointButton) controlLayout.addWidget(self.bpointButton) controlLayout.addWidget(self.cutButton) controlLayout.addWidget(self.lbl) controlLayout.addWidget(self.positionSlider) controlLayout.addWidget(self.elbl) layout0 = QVBoxLayout() layout0.setContentsMargins(0, 0, 0, 0) layout0.addWidget(self.videoWidget) layout0.addLayout(controlLayout) self.setLayout(layout0) self.widescreen = True self.setAcceptDrops(True) self.setWindowTitle("QT5 Player") #self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) self.setGeometry(300, 200, 400, 290) self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.customContextMenuRequested[QtCore.QPoint].connect( self.contextMenuRequested) #self.hideSlider() self.show() #self.playFromURL() ### shortcuts ### self.shortcut = QShortcut(QKeySequence('q'), self) self.shortcut.activated.connect(self.handleQuit) self.shortcut = QShortcut(QKeySequence('o'), self) self.shortcut.activated.connect(self.openFile) self.shortcut = QShortcut(QKeySequence(' '), self) self.shortcut.activated.connect(self.play) self.shortcut = QShortcut(QKeySequence('s'), self) self.shortcut.activated.connect(self.toggleSlider) self.shortcut = QShortcut(QKeySequence('v'), self) self.shortcut.activated.connect(self.setPointA) self.shortcut = QShortcut(QKeySequence('b'), self) self.shortcut.activated.connect(self.setPointB) self.shortcut = QShortcut(QKeySequence(Qt.Key_Right), self) self.shortcut.activated.connect(self.forwardSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Left), self) self.shortcut.activated.connect(self.backSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Up), self) self.shortcut.activated.connect(self.volumeUp) self.shortcut = QShortcut(QKeySequence(Qt.Key_Down), self) self.shortcut.activated.connect(self.volumeDown) self.shortcut = QShortcut( QKeySequence(Qt.ShiftModifier + Qt.Key_Right), self) self.shortcut.activated.connect(self.forwardSlider10) self.shortcut = QShortcut(QKeySequence(Qt.ShiftModifier + Qt.Key_Left), self) self.shortcut.activated.connect(self.backSlider10) self.mediaPlayer.setVideoOutput(self.videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.positionChanged.connect(self.handle_label) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError) self.apoint = 0 self.bpoint = 0 self.inputfile = pathlib.Path()
def __init__(self, parent=None): super(VideoPlayer, self).__init__(parent) self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) iconSize = QSize(12, 12) videoWidget = QVideoWidget() openButton = QPushButton("Open Video") openButton.setToolTip("Open Video File") openButton.setStatusTip("Open Video File") openButton.setFixedHeight(24) openButton.setFont(QFont("Noto Sans", 10)) openButton.clicked.connect(self.abrir) self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setFixedHeight(24) self.playButton.setIconSize(iconSize) self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) #进度条 self.positionSlider = QSlider(Qt.Horizontal) self.positionSlider.setRange(0, 0) self.positionSlider.sliderMoved.connect(self.setPosition) #音量条 self.volumeSlider = QSlider(Qt.Horizontal) self.volumeSlider.setRange(0, 100) self.volumeSlider.sliderMoved.connect(self.setVolume) self.volumeLabel = QLabel() self.volumeLabel.setText(" Volume Bar --> ") self.volumeLabel.setFont(QFont("Noto Sans", 10, QFont.Bold)) #Information bar self.statusBar = QStatusBar() self.statusBar.setFont(QFont("Noto Sans", 7)) self.statusBar.setFixedHeight(14) controlLayout = QHBoxLayout() controlLayout.setContentsMargins(0, 0, 0, 0) controlLayout.addWidget(openButton) controlLayout.addWidget(self.playButton) controlLayout.addWidget(self.positionSlider) layoutLine2 = QHBoxLayout() layoutLine2.setContentsMargins(0, 0, 0, 0) layoutLine2.addWidget(self.volumeLabel) layoutLine2.addWidget(self.volumeSlider) layout = QVBoxLayout() layout.addWidget(videoWidget) layout.addLayout(controlLayout) layout.addLayout(layoutLine2) layout.addWidget(self.statusBar) self.setLayout(layout) self.mediaPlayer.setVideoOutput(videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.volumeChanged.connect(self.volumeChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError) self.statusBar.showMessage("Ready")
def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() self.samples = None self.sampling_rate = None self.samples_after = None self.first_turn = True # This Prevents the Spectrogram range variables from being overwritten self.PLOT_DIR = 'Plots' self.PDF_DIR = 'PDFs' self.ui.save_session_data.clicked.connect(lambda: self.save_session()) self.ui.actionSave.triggered.connect(lambda: self.save_session()) self.audio_player_before = QMediaPlayer() self.audio_player_after = QMediaPlayer() self.audio_player_before.setNotifyInterval(1) self.audio_player_after.setNotifyInterval(1) self.bands_powers = [0.0, 0.25, 0.50, 0.75, 1.0, 2.0, 3.0, 4.0, 5.0] self.spectrogram_power_range = { 'min': np.array([]), 'max': np.array([]) } self.ui.min_pixel_intensity.sliderReleased.connect( lambda: self.spectrogram_pixels_intensity('min')) self.ui.max_pixel_intensity.sliderReleased.connect( lambda: self.spectrogram_pixels_intensity('max')) self.spectrogram_time_min, self.spectrogram_time_max = 0, 0 # Sync With Play self.band_slider = {} self.band_label = {} for index in range(10): self.band_slider[index] = getattr(self.ui, 'band_{}'.format(index + 1)) self.band_label[index] = getattr(self.ui, 'band_{}_label'.format(index + 1)) for slider in self.band_slider.values(): slider.setDisabled(True) slider.setStyleSheet('selection-background-color: grey') for index, slider in self.band_slider.items(): slider.sliderReleased.connect( lambda index=index: self.slider_gain_updated(index)) self.available_palettes = [ 'twilight', 'Blues', 'Greys', 'ocean', 'nipy_spectral' ] self.current_color_palette = self.available_palettes[0] self.modified_signal = np.array([]) self.current_slider_gain = [1.0] * 10 self.controlers = {'before': [], 'after': []} for button, function in zip( ['zoom_in', 'zoom_out', 'jump_forward', 'jump_back'], [self.zoomin, self.zoomout, self.forward, self.back]): self.controlers['before'].append( (getattr(self.ui, '{}_btn_before'.format(button)), function)) self.controlers['after'].append( (getattr(self.ui, '{}_btn_after'.format(button)), function)) for channel in self.controlers.values(): for signal in channel: signal[0].clicked.connect(signal[1]) self.plot_widget = { 'before': self.ui.graph_before, 'after': self.ui.graph_after } self.spectrogram_widget = { 'before': self.ui.spectrogram_before, 'after': self.ui.spectrogram_after } self.data_line = {'before': None, 'after': None} self.playback_position = {'before': None, 'after': None} self.time_seeker = { 'before': self.ui.time_seeker_before, 'after': self.ui.time_seeker_after } self.total_time = { 'before': self.ui.total_time_before, 'after': self.ui.total_time_after } self.ui.actionExit.triggered.connect(self.close) self.ui.actionNew.triggered.connect(self.new_instance) self.ui.actionOpen.triggered.connect(self.open_audio_file) self.ui.play_btn_before.clicked.connect(self.audio_player_before.play) self.ui.pause_btn_before.clicked.connect( self.audio_player_before.pause) self.ui.stop_btn_before.clicked.connect(self.audio_player_before.stop) self.ui.play_btn_after.clicked.connect(self.audio_player_after.play) self.ui.pause_btn_after.clicked.connect(self.audio_player_after.pause) self.ui.stop_btn_after.clicked.connect(self.audio_player_after.stop) self.ui.palettes_box.currentTextChanged.connect(self.change_palette) self.ui.playback_speed_before.currentIndexChanged.connect( lambda: self.audio_player_before.setPlaybackRate( float(self.ui.playback_speed_before.currentText()[1:]))) self.audio_player_before.durationChanged.connect( lambda duration: self.update_duration(duration, 'before')) self.ui.playback_speed_after.currentIndexChanged.connect( lambda: self.audio_player_after.setPlaybackRate( float(self.ui.playback_speed_after.currentText()[1:]))) self.audio_player_after.durationChanged.connect( lambda duration: self.update_duration(duration, 'after'))
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(1666, 900) self.treeView = QtWidgets.QTreeView(Dialog) self.treeView.setGeometry(QtCore.QRect(50, 60, 1561, 191)) self.treeView.setObjectName("treeView") self.label = QtWidgets.QLabel(Dialog) self.label.setGeometry(QtCore.QRect(50, 280, 720, 405)) font = QtGui.QFont() font.setPointSize(12) self.label.setFont(font) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(Dialog) self.label_2.setGeometry(QtCore.QRect(890, 280, 720, 405)) self.wgt_video_1 = QVideoWidget(Dialog) self.wgt_video_1.setGeometry(QtCore.QRect(50, 280, 720, 405)) self.player_1 = QMediaPlayer() self.player_1.setVideoOutput(self.wgt_video_1) self.wgt_video_1.setObjectName("widget") self.wgt_video_2 = QVideoWidget(Dialog) self.wgt_video_2.setGeometry(QtCore.QRect(890, 280, 720, 405)) self.player_2 = QMediaPlayer() self.player_2.setVideoOutput(self.wgt_video_2) self.wgt_video_2.setObjectName("widget") font = QtGui.QFont() font.setPointSize(12) self.label_2.setFont(font) self.label_2.setAlignment(QtCore.Qt.AlignCenter) self.label_2.setObjectName("label_2") self.groupBox = QtWidgets.QGroupBox(Dialog) self.groupBox.setGeometry(QtCore.QRect(50, 710, 1561, 151)) font = QtGui.QFont() font.setPointSize(12) self.groupBox.setFont(font) self.groupBox.setObjectName("groupBox") self.label_4 = QtWidgets.QLabel(self.groupBox) self.label_4.setGeometry(QtCore.QRect(20, 30, 1521, 111)) self.label_4.setObjectName("label_4") self.label_3 = QtWidgets.QLabel(Dialog) self.label_3.setGeometry(QtCore.QRect(50, 20, 361, 31)) font = QtGui.QFont() font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label_3.setFont(font) self.label_3.setObjectName("label_3") self.pushButton = QtWidgets.QPushButton(Dialog) self.pushButton.setGeometry(QtCore.QRect(780, 280, 101, 31)) font = QtGui.QFont() font.setPointSize(10) self.pushButton.setFont(font) self.pushButton.setObjectName("pushButton") self.pushButton_2 = QtWidgets.QPushButton(Dialog) self.pushButton_2.setGeometry(QtCore.QRect(780, 320, 51, 31)) self.pushButton_2.setObjectName("pushButton_2") self.pushButton_3 = QtWidgets.QPushButton(Dialog) self.pushButton_3.setGeometry(QtCore.QRect(830, 320, 51, 31)) self.pushButton_3.setObjectName("pushButton_3") self.pushButton_5 = QtWidgets.QPushButton(Dialog) self.pushButton_5.setGeometry(QtCore.QRect(780, 320, 51, 31)) self.pushButton_5.setObjectName("pushButton_2") self.pushButton_6 = QtWidgets.QPushButton(Dialog) self.pushButton_6.setGeometry(QtCore.QRect(830, 320, 51, 31)) self.pushButton_6.setObjectName("pushButton_3") self.pushButton_4 = QtWidgets.QPushButton(Dialog) self.pushButton_4.setGeometry(QtCore.QRect(780, 360, 101, 31)) font = QtGui.QFont() font.setPointSize(10) self.pushButton_4.setFont(font) self.pushButton_4.setObjectName("pushButton_4") self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
def __init__(self, parent=None): super(VideoWindow, self).__init__(parent) self.setWindowTitle("Video") self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) videoWidget = QVideoWidget() self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) self.positionSlider = QSlider(Qt.Horizontal) self.positionSlider.setRange(0, 0) self.positionSlider.sliderMoved.connect(self.setPosition) self.errorLabel = QLabel() self.errorLabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) # Create new action openAction = QAction(QIcon('open.png'), '&Open', self) openAction.setShortcut('Ctrl+O') openAction.setStatusTip('Open movie') openAction.triggered.connect(self.openFile) # Create exit action exitAction = QAction(QIcon('exit.png'), '&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(self.exitCall) # Create menu bar and add action menuBar = self.menuBar() fileMenu = menuBar.addMenu('&File') #fileMenu.addAction(newAction) fileMenu.addAction(openAction) fileMenu.addAction(exitAction) # Create a widget for window contents wid = QWidget(self) self.setCentralWidget(wid) start_time = time.time() # Create side layout mainLayout = QHBoxLayout() self.label = QtWidgets.QLabel("Faces: ") self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel("Total: ") self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel("Tempo: %.2f" % (time.time() - start_time)) self.label_3.setObjectName("label_3") self.label_4 = QtWidgets.QLabel("") self.label_4.setObjectName("Duração: ") sideLayout = QVBoxLayout() sideLayout.setContentsMargins(0, 50, 0, 130) sideLayout.addWidget(self.label) sideLayout.addWidget(self.label_2) sideLayout.addWidget(self.label_3) sideLayout.addWidget(self.label_4) # Create layouts to place inside widget controlLayout = QHBoxLayout() controlLayout.setContentsMargins(0, 0, 0, 0) controlLayout.addWidget(self.playButton) controlLayout.addWidget(self.positionSlider) layout = QVBoxLayout() layout.setContentsMargins(150, 20, 20, 50) layout.addWidget(videoWidget) layout.addLayout(controlLayout) layout.addWidget(self.errorLabel) mainLayout.addLayout(sideLayout) mainLayout.addLayout(layout) # Set widget to contain window contents wid.setLayout(mainLayout) #wid.setLayout(sideLayout) self.mediaPlayer.setVideoOutput(videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError)
def __init__(self, aPath, parent=None): super(VideoPlayer, self).__init__(parent) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAcceptDrops(True) self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.StreamPlayback) self.mediaPlayer.setVolume(80) self.videoWidget = QVideoWidget(self) self.videoWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.videoWidget.setMinimumSize(QSize(640, 360)) self.lbl = QLineEdit('00:00:00') self.lbl.setReadOnly(True) self.lbl.setFixedWidth(70) self.lbl.setUpdatesEnabled(True) self.lbl.setStyleSheet(stylesheet(self)) self.elbl = QLineEdit('00:00:00') self.elbl.setReadOnly(True) self.elbl.setFixedWidth(70) self.elbl.setUpdatesEnabled(True) self.elbl.setStyleSheet(stylesheet(self)) self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setFixedWidth(32) self.playButton.setStyleSheet("background-color: black") self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) self.positionSlider = QSlider(Qt.Horizontal, self) self.positionSlider.setStyleSheet(stylesheet(self)) self.positionSlider.setRange(0, 100) self.positionSlider.sliderMoved.connect(self.setPosition) self.positionSlider.sliderMoved.connect(self.handleLabel) self.positionSlider.setSingleStep(2) self.positionSlider.setPageStep(20) self.positionSlider.setAttribute(Qt.WA_TranslucentBackground, True) self.clip = QApplication.clipboard() self.process = QProcess(self) self.process.readyRead.connect(self.dataReady) self.process.finished.connect(self.playFromURL) self.myurl = "" # channel list self.channelList = QListView(self) self.channelList.setMinimumSize(QSize(150, 0)) self.channelList.setMaximumSize(QSize(150, 4000)) self.channelList.setFrameShape(QFrame.Box) self.channelList.setObjectName("channelList") self.channelList.setStyleSheet("background-color: black; color: #585858;") self.channelList.setFocus() # for adding items to list must create a model self.model = QStandardItemModel() self.channelList.setModel(self.model) self.controlLayout = QHBoxLayout() self.controlLayout.setContentsMargins(5, 0, 5, 0) self.controlLayout.addWidget(self.playButton) self.controlLayout.addWidget(self.lbl) self.controlLayout.addWidget(self.positionSlider) self.controlLayout.addWidget(self.elbl) self.mainLayout = QHBoxLayout() # contains video and cotrol widgets to the left side self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.videoWidget) self.layout.addLayout(self.controlLayout) # adds channels list to the right self.mainLayout.addLayout(self.layout) self.mainLayout.addWidget(self.channelList) self.setLayout(self.mainLayout) self.myinfo = "©2020\nTIVOpy v1.0" self.widescreen = True #### shortcuts #### self.shortcut = QShortcut(QKeySequence("q"), self) self.shortcut.activated.connect(self.handleQuit) self.shortcut = QShortcut(QKeySequence("u"), self) self.shortcut.activated.connect(self.playFromURL) self.shortcut = QShortcut(QKeySequence(Qt.Key_Space), self) self.shortcut.activated.connect(self.play) self.shortcut = QShortcut(QKeySequence(Qt.Key_F), self) self.shortcut.activated.connect(self.handleFullscreen) self.shortcut = QShortcut(QKeySequence(Qt.Key_Escape), self) self.shortcut.activated.connect(self.exitFullscreen) self.shortcut.activated.connect(self.handleFullscreen) self.shortcut = QShortcut(QKeySequence("i"), self) self.shortcut.activated.connect(self.handleInfo) self.shortcut = QShortcut(QKeySequence("s"), self) self.shortcut.activated.connect(self.toggleSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Right), self) self.shortcut.activated.connect(self.forwardSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Left), self) self.shortcut.activated.connect(self.backSlider) self.mediaPlayer.setVideoOutput(self.videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.positionChanged.connect(self.handleLabel) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError) self.populateChannelList() self.selectChannel() self.initialPlay()
def __init__(self, sqlConn, account): # Save the sqlConnection for later self.sqlConnection = sqlConn # Call to superclass constructor QMainWindow.__init__(self) # Save the variables for later self.account = account self.title = 'Payment Information' # If the user has an account, retrieve the user data from the database and use it # to populate the form try: if self.account != 0: sql = '''SELECT * FROM BlueSky.Payment WHERE paymentID = (SELECT paymentID FROM BlueSky.Login WHERE loginID = %s)''' self.sqlConnection.cursor.execute(sql, self.account) self.paymentData = self.sqlConnection.cursor.fetchall() except Exception as e: print(str(e)) # Create the window and configure it self.setWindowTitle(self.title) self.setWindowIcon(QIcon('media/favicon.ico')) self.setFixedSize(900, 750) # Payment Information label self.lblPaymentInformation = QLabel("Payment Information", self) self.lblPaymentInformation.setFont(self.FONT_LARGE_BOLD) self.lblPaymentInformation.adjustSize() self.lblPaymentInformation.move(150, 20) # Credit Cards image self.lblCreditCardsImage = QLabel(self) imgCreditCards = QPixmap() imgCreditCards.load('media/creditCards.jpg') imgCreditCards = imgCreditCards.scaledToWidth(400) self.lblCreditCardsImage.setPixmap(imgCreditCards) self.lblCreditCardsImage.setGeometry(150, 65, 400, 62) # Billing Information Label self.lblBillingInformation = QLabel("Billing Information", self) self.lblBillingInformation.setFont(self.FONT_MEDIUM) self.lblBillingInformation.adjustSize() self.lblBillingInformation.move(150, 140) # Instructions label self.lblInstructions = QLabel( "Please enter your full name and address below as they appear on your debit/credit card billing statement.", self) self.lblInstructions.setFont(self.FONT_SMALL) self.lblInstructions.adjustSize() self.lblInstructions.move(150, 170) # Card Number text box self.txtCardNumber = QLineEdit(self) if self.account != 0: self.txtCardNumber.setText(self.paymentData[0][12]) else: self.txtCardNumber.setPlaceholderText("Card number *") self.txtCardNumber.setGeometry(150, 200, 200, 31) # Card CVV text box self.txtCVV = QLineEdit(self) if self.account != 0: self.txtCVV.setText(self.paymentData[0][13]) else: self.txtCVV.setPlaceholderText("CVV *") self.txtCVV.setGeometry(370, 200, 50, 31) # Expiration Month drop down menu self.cmbExpirationMonth = QComboBox(self) self.cmbExpirationMonth.addItem("Expiration month *") self.cmbExpirationMonth.addItem("January") self.cmbExpirationMonth.addItem("February") self.cmbExpirationMonth.addItem("March") self.cmbExpirationMonth.addItem("April") self.cmbExpirationMonth.addItem("May") self.cmbExpirationMonth.addItem("June") self.cmbExpirationMonth.addItem("July") self.cmbExpirationMonth.addItem("August") self.cmbExpirationMonth.addItem("September") self.cmbExpirationMonth.addItem("October") self.cmbExpirationMonth.addItem("November") self.cmbExpirationMonth.addItem("December") self.cmbExpirationMonth.setGeometry(150, 250, 200, 31) if self.account != 0: self.cmbExpirationMonth.setCurrentIndex(self.paymentData[0][14]) else: self.cmbExpirationMonth.setCurrentIndex(0) # Expiration Year drop down menu self.cmbExpirationYear = QComboBox(self) self.cmbExpirationYear.addItem("Year *") currentYear = datetime.datetime.today().year for y in range(currentYear, currentYear + 10): self.cmbExpirationYear.addItem(str(y)) self.cmbExpirationYear.setGeometry(370, 250, 70, 31) if self.account != 0: index = self.cmbExpirationYear.findText( str(self.paymentData[0][15])) self.cmbExpirationYear.setCurrentIndex(index) else: self.cmbExpirationYear.setCurrentIndex(0) # Full Name text box self.txtFullName = QLineEdit(self) if self.account != 0: self.txtFullName.setText(self.paymentData[0][6]) else: self.txtFullName.setPlaceholderText( "Full name as it appears on your card *") self.txtFullName.setGeometry(150, 300, 550, 31) # Billing Address text boxes self.txtBillingAddress = QLineEdit(self) if self.account != 0: self.txtBillingAddress.setText(self.paymentData[0][7]) else: self.txtBillingAddress.setPlaceholderText("Billing address *") self.txtBillingAddress.setGeometry(150, 350, 300, 31) # City/Town/Department text box self.txtCity = QLineEdit(self) if self.account != 0: self.txtCity.setText(self.paymentData[0][8]) else: self.txtCity.setPlaceholderText("City/town/department *") self.txtCity.setGeometry(150, 400, 180, 31) # State/Province/Region/County text box self.txtState = QLineEdit(self) if self.account != 0: self.txtState.setText(self.paymentData[0][9]) else: self.txtState.setPlaceholderText("State/province/region/county *") self.txtState.setGeometry(340, 400, 200, 31) # ZIP/Postal Code text box self.txtZipCode = QLineEdit(self) if self.account != 0: self.txtZipCode.setText(self.paymentData[0][11]) else: self.txtZipCode.setPlaceholderText("ZIP/Postal code *") self.txtZipCode.setGeometry(550, 400, 110, 31) # Country drop down menu self.cmbCountry = QComboBox(self) self.cmbCountry.addItem("United States") self.cmbCountry.addItem("Canada") self.cmbCountry.addItem("United Kingdom") self.cmbCountry.addItem("France") self.cmbCountry.addItem("Vietnam") self.cmbCountry.setGeometry(150, 450, 200, 31) if self.account != 0: index = self.cmbCountry.findText(self.paymentData[0][10]) self.cmbCountry.setCurrentIndex(index) else: self.cmbCountry.setCurrentIndex(0) # Total Price label try: # Retrieve the price and number of tickets purchased from the database countSQL = '''SELECT * FROM BlueSky.Ticket WHERE paymentID = (SELECT MAX(paymentID) FROM BlueSky.Payment)''' count = self.sqlConnection.cursor.execute(countSQL) priceSQL = '''SELECT price FROM BlueSky.Flight f JOIN BlueSky.Payment p ON f.flightID = p.flightID WHERE p.paymentID = (SELECT MAX(paymentID) FROM BlueSky.Payment)''' self.sqlConnection.cursor.execute(priceSQL) price = self.sqlConnection.cursor.fetchone() # Check to see if there is a return flight returnFlightSQL = '''SELECT returnFlightID FROM BlueSky.Payment WHERE paymentID = (SELECT MAX(paymentID) FROM BlueSky.Payment)''' self.sqlConnection.cursor.execute(returnFlightSQL) returnFlight = self.sqlConnection.cursor.fetchone() if returnFlight[ 0] == 0: # Calculate the total price and display it on the form totalPrice = count * price[0] else: # Account for return flight costs if necessary returnPriceSQL = '''SELECT price FROM BlueSky.Flight f JOIN BlueSky.Payment p ON f.flightID = p.returnFlightID WHERE p.paymentID = (SELECT MAX(paymentID) FROM BlueSky.Payment)''' self.sqlConnection.cursor.execute(returnPriceSQL) returnPrice = self.sqlConnection.cursor.fetchone() totalPrice = count * (price[0] + returnPrice[0]) self.lblTotalPrice = QLabel("Total: $" + str(totalPrice), self) self.lblTotalPrice.setFont(self.FONT_LARGE) self.lblTotalPrice.adjustSize() self.lblTotalPrice.move(150, 510) except Exception as e: print(str(e)) # Purchase button self.btnPurchase = QPushButton("Purchase", self) self.btnPurchase.setFont(self.FONT_LARGE_BOLD) self.btnPurchase.clicked.connect(self.handlePurchaseButton) self.btnPurchase.resize(175, 50) self.btnPurchase.move(525, 580) # Add the loading gif animation self.movLoadingAnimation = QMovie("media/loading.gif") self.movLoadingAnimation.finished.connect( self.handleLoadingAnimationFinished) self.lblGifDisplay = QLabel(self) self.lblGifDisplay.setMovie(self.movLoadingAnimation) self.lblGifDisplay.resize(134, 75) self.lblGifDisplay.move(710, 580) # Add the loading sound self.medPaymentSound = QMediaPlayer() self.medPaymentSound.setMedia( QMediaContent(QUrl('media/cash-register.wav'))) # Purchase and Create Account Button if self.account == 0: self.btnCreateAccount = QPushButton("Purchase and Create Account", self) self.btnCreateAccount.setFont(self.FONT_LARGE_BOLD) self.btnCreateAccount.clicked.connect(self.handleAccountButton) self.btnCreateAccount.resize(450, 50) self.btnCreateAccount.move(210, 650) # Clear button self.btnClear = QPushButton("Clear", self) self.btnClear.setFont(self.FONT_LARGE_BOLD) self.btnClear.clicked.connect(self.handleClearButton) self.btnClear.resize(175, 50) self.btnClear.move(350, 580) # Quit button self.btnQuit = QPushButton("Quit", self) self.btnQuit.setFont(self.FONT_LARGE_BOLD) self.btnQuit.clicked.connect(self.handleQuitButton) self.btnQuit.resize(175, 50) self.btnQuit.move(175, 580)
def __init__(self, parent=None): super().__init__(parent) # load config self.data = yaml_loader() # load ui self.setupUi(self) # load icons self.setWindowTitle("Sputofy") self.setWindowIcon(QIcon(os.path.join(RES_PATH, "logo.svg"))) loopIcon = QIcon() loopIcon.addPixmap(QPixmap(os.path.join(RES_PATH, "loopIconOFF.svg"))) self.loopBtn.setIcon(loopIcon) prevIcon = QIcon() prevIcon.addPixmap(QPixmap(os.path.join(RES_PATH, "backwardIcon.svg"))) self.prevBtn.setIcon(prevIcon) playIcon = QIcon() playIcon.addPixmap(QPixmap(os.path.join(RES_PATH, "playIcon.svg"))) self.playBtn.setIcon(playIcon) nextIcon = QIcon() nextIcon.addPixmap(QPixmap(os.path.join(RES_PATH, "forwardIcon.svg"))) self.nextBtn.setIcon(nextIcon) randomIcon = QIcon() randomIcon.addPixmap( QPixmap(os.path.join(RES_PATH, "randomIconOFF.svg"))) self.randomBtn.setIcon(randomIcon) volumeIcon = QIcon() volumeIcon.addPixmap(QPixmap(os.path.join(RES_PATH, "volumeIcon.svg"))) self.volumeBtn.setIcon(volumeIcon) # window's settings self.xCor = self.data['last_position']['xPos'] self.yCor = self.data['last_position']['yPos'] self.widthSize = self.data['last_window_size']['width'] self.heightSize = self.data['last_window_size']['height'] self.setGeometry(self.xCor, self.yCor, self.widthSize, self.heightSize) # load YouTubeToMP3 self.YouTubeToMP3 = YouTubeToMP3Window() # open YouTubeToMP3 using button self.actionYT_MP3.triggered.connect(self.YouTubeToMP3.show_window) # info action self.actionInfo.triggered.connect(self.info_handle) #=========================== mediaplayer ============================== # create media player object self.mediaPlayer = QMediaPlayer(None) # open button self.actionOpen_Song.triggered.connect(self.open_song) self.actionOpen_Folder.triggered.connect(self.open_folder) # play button self.playBtn.setEnabled(False) self.playBtn.clicked.connect( self.play_video ) # when btn is pressed: if it is playing it pause, if it is paused it plays # QShortcut(QKeySequence("Space"), self).activated.connect(self.play_video)metodo da ricordare in caso di problemi #TODO # duration slider self.durationSlider.setEnabled(False) self.durationSliderMaxValue = 0 self.durationSlider.valueChanged.connect( self.mediaPlayer.setPosition ) # set mediaPlayer position using the value took from the slider QShortcut('Right', self, lambda: self.durationSlider.setValue( self.durationSlider.value() + 10000)) # 1s = 1000ms QShortcut('Left', self, lambda: self.durationSlider.setValue( self.durationSlider.value() - 10000)) # 1s = 1000ms QShortcut('Shift+Right', self, lambda: self.durationSlider.setValue( self.durationSliderMaxValue - 1000)) # jump to the end-1s of song QShortcut('Shift+Left', self, lambda: self.durationSlider.setValue(0)) # restart song # volumeSlider self.volumeSlider.setProperty("value", 100) self.volumeSlider.setRange(0, 100) self.volumeSlider.setValue( self.data['volume'] if self.data['volume'] != 0 else self.data['volume'] + 1 ) # set slider value | if saved volume is equal to 0 load with volume = 1 else load the saved volume self.mediaPlayer.setVolume( self.data['volume'] if self.data['volume'] != 0 else self.data['volume'] + 1 ) # set mediaPlayer volume | if saved volume is equal to 0 load with volume = 1 else load the saved volume self.volumeLabel.setText( f"{self.data['volume']}%" if self.data['volume'] != 0 else f"{self.data['volume']+1}%" ) # set volume label text | if saved volume is equal to 0 load with volume = 1 else load the saved volume self.volumeSlider.valueChanged.connect( self.mediaPlayer.setVolume ) # set mediaPlayer volume using the value took from the slider QShortcut('Up', self, lambda: self.volumeSlider.setValue( self.volumeSlider.value() + 1)) # volume + 1 QShortcut('Down', self, lambda: self.volumeSlider.setValue( self.volumeSlider.value() - 1)) # volume - 1 QShortcut( 'Shift+Up', self, lambda: self.volumeSlider.setValue(100)) # set maximum volume QShortcut( 'Shift+Down', self, lambda: self.volumeSlider.setValue(0)) # set minimun volume(mute) # volumeBtn self.volumeBtn.clicked.connect( self.volume_toggle) # mute/unmute volume pressing btn self.isMuted = False # starting with a non-muted volume self.previousVolume = self.data[ 'volume'] # loading last registered volume # media player signals self.mediaPlayer.durationChanged.connect( self.duration_changed) # set range of duration slider self.mediaPlayer.positionChanged.connect( self.position_changed) # duration slider progress self.mediaPlayer.stateChanged.connect( self.player_state) # see when it's playing or in pause self.mediaPlayer.volumeChanged.connect( self.volume_icon) # change volumebtn icon #=========================== playlist ============================== # create the playlist self.playlist = QMediaPlaylist() self.playlist.setPlaybackMode(2) self.mediaPlayer.setPlaylist(self.playlist) # clear the playlist self.playlistIsEmpty = True # playlistList model self.model = PlaylistModel(self.playlist) self.playlistView.setModel(self.model) self.playlist.currentIndexChanged.connect( self.playlist_position_changed) selection_model = self.playlistView.selectionModel() selection_model.selectionChanged.connect( self.playlist_selection_changed) #=========================== playlist function ============================== self.mediaList = [] # array of loaded songs self.currentPlaylist = "" # current loaded playlist name self.isCustomPlaylist = False # add song name on title self.playlist.currentMediaChanged.connect(self.set_title) # playlist buttons self.nextBtn.clicked.connect(self.next_song) # seek track forward self.prevBtn.clicked.connect(self.prev_song) # seek track backward self.mediaPlayer.mediaStatusChanged.connect( self.auto_next_track ) # once song is ended seek track forward and play it self.actionLoopIt.triggered.connect( self.loop_song) # (1) loop the same song self.actionShuffle.triggered.connect( self.shuffle_playlist) # change song's order self.loopBtn.clicked.connect(self.loop) # (3) loop the playlist self.randomBtn.clicked.connect( self.random) # (4) play random song without end # create new playlist self.actionCreatePlaylist.triggered.connect(self.custom_playlist) # delete current playlist self.actionDeletePlaylist.triggered.connect(self.delete_playlist) # remove all songs self.actionClearQueue.triggered.connect(self.clear_queue) # load playlist self.actionDict = {} # dictionary of action Objects for action in self.data['playlistList']: self.actionDict[action] = self.menuPlaylist.addAction( action, partial(self.load_playlist, action)) if len(self.data['playlistList']) == 0: self.menuPlaylist.menuAction().setVisible(False)
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) while self.name1 == '' or self.group1 == '': dialog = StartDialog(self) if dialog.exec_(): self.name1 = dialog.lineEdit.text() self.group1 = dialog.lineEdit_2.text() self.duration = 0 self.playerState = QMediaPlayer.StoppedState self.timerAud = QtCore.QTimer(self) self.player = QMediaPlayer() self.playlist = QMediaPlaylist() self.player.setPlaylist(self.playlist) # frame with buttons play and stop, and duration label self.frame = QtWidgets.QFrame(self.ui.scrollAreaWidgetContents) self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frame.setFrameShadow(QtWidgets.QFrame.Raised) self.frame.setObjectName("frame") self.horizontalLayout = QtWidgets.QHBoxLayout(self.frame) self.horizontalLayout.setObjectName("horizontalLayout") self.pushButton = QtWidgets.QPushButton(self.frame) self.pushButton.setObjectName("pushButton") self.horizontalLayout.addWidget(self.pushButton) self.pushButton_3 = QtWidgets.QPushButton(self.frame) self.pushButton_3.setObjectName("pushButton_3") self.horizontalLayout.addWidget(self.pushButton_3) self.labelDuration = QtWidgets.QLabel(self.frame) self.labelDuration.setText('0') self.horizontalLayout.addWidget(self.labelDuration) # creating timer self.timer = QtCore.QTimer(self) # xml handling (read & mix) self.mixXml() # read to DOM self.readToDom() # assigning layout to the scrollarea self.verticalLayout = QtWidgets.QVBoxLayout( self.ui.scrollAreaWidgetContents) self.verticalLayout.setObjectName("verticalLayout") # adding title self.trTitle = QtWidgets.QLabel(self.ui.scrollAreaWidgetContents) self.trTitle.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.trTitle.setText('') # adding standart widgets for listening self.verticalLayout.addWidget(self.trTitle) self.lblAud = QtWidgets.QLabel(self.ui.scrollAreaWidgetContents) self.lblAud.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.lblAud.setText('') self.horizontalSlider = QtWidgets.QSlider( self.ui.scrollAreaWidgetContents) self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal) self.horizontalSlider.setObjectName("horizontalSlider") # adding frame self.verticalLayout.addWidget(self.lblAud) self.verticalLayout.addWidget(self.horizontalSlider) self.verticalLayout.addWidget(self.frame) self.pushButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_MediaPlay)) self.pushButton_3.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_MediaStop)) self.pushButton_3.setEnabled(False) # adding widgets to the scrollarea self.addWidgetsToInterface() self.timer.timeout.connect(lambda: self.updater(self.timeSeconds)) # starting timer self.timer.start(1000) self.player.durationChanged.connect(self.durationChanged1) self.player.positionChanged.connect(self.positionChanged1) self.player.stateChanged.connect(self.setState) self.horizontalSlider.setRange(0, self.player.duration() / 1000) self.pushButton.clicked.connect(self.play1) self.pushButton_3.clicked.connect(self.stop1) self.horizontalSlider.sliderMoved.connect(self.changePosition) self.ui.pushButton.clicked.connect(self.finish)
def __init__(self): QThread.__init__(self) self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.StreamPlayback) pygame.init() pygame.mixer.music.load("audio/end_2.mp3")