def set_playlist(self): self.player = M.QMediaPlayer(self) self.player2 = M.QMediaPlayer(self) self.playlist = M.QMediaPlaylist(self.player) self.playlist2 = M.QMediaPlaylist(self.player2) for song in self.all_songs: url = C.QUrl.fromLocalFile(song[:-1]) content = M.QMediaContent(url) self.playlist.addMedia(content) self.playlist2.addMedia(content) self.playlist.setCurrentIndex(0) self.playlist2.shuffle() self.playlist2.setCurrentIndex(0) self.player.setPlaylist(self.playlist) self.player2.setPlaylist(self.playlist2)
def _make_playlist(self): playlist = QtMultimedia.QMediaPlaylist() for song in self.songs_current: song_file = QtCore.QUrl.fromLocalFile(song.path) media = QtMultimedia.QMediaContent(song_file) playlist.addMedia(media) self.playlist = playlist
def __init__(self): back = QtCore.QUrl.fromLocalFile(self.get_path('background.mp3')) self.back_playlist = QtMultimedia.QMediaPlaylist() self.back_playlist.addMedia(QtMultimedia.QMediaContent(back)) self.back_playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) self.back_player = QtMultimedia.QMediaPlayer() self.back_player.setPlaylist(self.back_playlist) hit = QtCore.QUrl.fromLocalFile(self.get_path('hit.mp3')) self.hit_player = QtMultimedia.QMediaPlayer() self.hit_player.setMedia(QtMultimedia.QMediaContent(hit)) win = QtCore.QUrl.fromLocalFile(self.get_path('win.mp3')) self.win_player = QtMultimedia.QMediaPlayer() self.win_player.setMedia(QtMultimedia.QMediaContent(win)) game_over = QtCore.QUrl.fromLocalFile(self.get_path('game_over.mp3')) self.game_over_player = QtMultimedia.QMediaPlayer() self.game_over_player.setMedia(QtMultimedia.QMediaContent(game_over)) dying = QtCore.QUrl.fromLocalFile(self.get_path('dying.mp3')) self.dying_player = QtMultimedia.QMediaPlayer() self.dying_player.setMedia(QtMultimedia.QMediaContent(dying)) hit_mystery_ship = QtCore.QUrl.fromLocalFile( self.get_path('hit_mystery.mp3')) self.hit_mystery_ship_player = QtMultimedia.QMediaPlayer() self.hit_mystery_ship_player.setMedia( QtMultimedia.QMediaContent(hit_mystery_ship))
def set_file(self, url): if url.scheme() == '': url.setScheme('file') content = qtmm.QMediaContent(url) self.playlist = qtmm.QMediaPlaylist() self.playlist.addMedia(content) self.playlist.setCurrentIndex(1) self.player.setPlaylist(self.playlist)
def play(self): """Play selected tracks with an internal player""" self._player.stop() playlist = QtMultimedia.QMediaPlaylist(self) playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Sequential) playlist.addMedia([QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(file.filename)) for file in iter_files_from_objects(self._selected_objects)]) self._player.setPlaylist(playlist) self._player.play()
def set_file(self, url): self.label.setText(url.fileName()) content = qtmm.QMediaContent(url) # self.player.setMedia(content) self.playlist = qtmm.QMediaPlaylist() self.playlist.addMedia(content) self.playlist.setCurrentIndex(1) self.player.setPlaylist(self.playlist) self.loop_cb.setChecked(False)
def __init__(self, parent): """ The constructor for the display form. :param parent: The parent widget. """ super(AudioPlayer, self).__init__(parent) self.player = QtMultimedia.QMediaPlayer() self.playlist = QtMultimedia.QMediaPlaylist(self.player) self.volume_slider = None self.player.setPlaylist(self.playlist) self.player.positionChanged.connect(self._on_position_changed)
def startAudio(self): self.playlist = QtMultimedia.QMediaPlaylist() self.playlist.addMedia( QtMultimedia.QMediaContent( QtCore.QUrl.fromLocalFile("Files\\Sound\\MainTheme.mp3"))) self.playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) self.sound = QtMultimedia.QSound("Files\\Sound\\ClickSound.wav") self.audio = QtMultimedia.QMediaPlayer() self.audio.setPlaylist(self.playlist) self.audio.play() self.audio.setVolume(20)
def set_file(self, url): self.label.setText(url.fileName()) if url.scheme() == '': url.setScheme('file') content = qtmm.QMediaContent(url) #self.player.setMedia(content) # Looping # must retain a reference to the playlist # hence self.playlist self.playlist = qtmm.QMediaPlaylist() self.playlist.addMedia(content) self.playlist.setCurrentIndex(1) self.player.setPlaylist(self.playlist) self.loop_cb.setChecked(False)
def __init__(self, static_folder: str, port: int): self.static_folder: str = static_folder self.url: str = f"http://127.0.0.1:{port}" self.app: QtWidgets.QApplication = QtWidgets.QApplication([]) self.view: QtWebEngineWidgets.QWebEngineView = QtWebEngineWidgets.QWebEngineView( self.app.activeModalWidget()) self.set_minimum_resolution() self.playlist: QtMultimedia.QMediaPlaylist = QtMultimedia.QMediaPlaylist( ) self.player: QtMultimedia.QMediaPlayer = QtMultimedia.QMediaPlayer( flags=QtMultimedia.QMediaPlayer.LowLatency) self.initialize_player()
def mediaplayer(self, path): #Create playList and add media self.playList = QtMultimedia.QMediaPlaylist() # self.playList.addMedia(QtMultimedia.QMediaContent(QtCore.QUrl(path))) self.playList.addMedia( QtMultimedia.QMediaContent(QtCore.QUrl('file:picture\Rebar.avi'))) self.playList.setCurrentIndex(1) self.playList.setPlaybackMode( QtMultimedia.QMediaPlaylist.CurrentItemInLoop) #Create player and add playlist to player self.player = QtMultimedia.QMediaPlayer() self.player.setPlaylist(self.playList) #Create play widgets self.playerWidgets = QtMultimediaWidgets.QVideoWidget() self.playerWidgets.show() self.player.setVideoOutput(self.playerWidgets) self.player.play()
def __init__(self, parent=None): super().__init__(parent) self.player = QtMultimedia.QMediaPlayer() self.player.positionChanged.connect(self.position_changed) self.player.setVolume(DEFAULT_VOLUME) self.playlist = QtMultimedia.QMediaPlaylist() self.sequence = None self.sound_array = None self.tmpfile_path = None self.play = QtWidgets.QPushButton(icon('play.png'), '') self.play.setFixedSize(self.BUTTON_SIZE, self.BUTTON_SIZE) self.play.released.connect(self._call_play) self.pause = QtWidgets.QPushButton(icon('pause.png'), '') self.pause.setFixedSize(self.BUTTON_SIZE, self.BUTTON_SIZE) self.pause.released.connect(self._call_pause) self.stop = QtWidgets.QPushButton(icon('stop.png'), '') self.stop.setFixedSize(self.BUTTON_SIZE, self.BUTTON_SIZE) self.stop.released.connect(self._call_stop) self.seeker = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.seeker.setRange(0, 100) self.seeker.setTracking(False) self.seeker.sliderMoved.connect(self.seek_position) self.volumelabel = QtWidgets.QLabel('volume:') self.volume = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.volume.setRange(0, 100) self.volume.setFixedWidth(60) self.volume.setValue(DEFAULT_VOLUME) self.volume.valueChanged.connect(self.player.setVolume) self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.play) self.layout.addWidget(self.pause) self.layout.addWidget(self.stop) self.layout.addWidget(self.seeker) self.layout.addWidget(self.volumelabel) self.layout.addWidget(self.volume)
def __init__(self, parent=None): super(VideoPlayer, self).__init__(parent) #self.frame = QtWidgets.QFrame() self.setMinimumSize(600, 400) self.layout = QtWidgets.QVBoxLayout(self) self.player = QtMultimedia.QMediaPlayer(self) self.player.setAudioRole(QtMultimedia.QAudio.VideoRole) self.playlist = QtMultimedia.QMediaPlaylist(self.player) self.playlist.addMedia(QtMultimedia.QMediaContent(self.playlist, QtCore.QUrl("video.mp4"))) self.video_widget = QtMultimediaWidgets.QVideoWidget(self) self.player.setVideoOutput(self.video_widget) self.layout.addWidget(self.video_widget) self.video_widget.show() self.playlist.setCurrentIndex(1) self.player.play()
def load_soundtrack_playlist(): """ Loads the play list of the soundtracks and replaces the file name with the full path. A playlist is a list where each entry is a list of two strings: file path, title """ global soundtrack_playlist # create playlist soundtrack_playlist = QtMultimedia.QMediaPlaylist() soundtrack_playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) # read information file data = utils.read_as_yaml(constants.SOUNDTRACK_INFO_FILE) # add the soundtrack folder to each file name for entry in data: file = constants.extend(constants.SOUNDTRACK_FOLDER, entry[0]) url = qt.local_url(file) media = QtMultimedia.QMediaContent(url) soundtrack_playlist.addMedia(media)
def __init__(self, parent=None, configs=None): super(WrapCelebrate, self).__init__(parent) self.setupUi(self) self.configs = configs self.move_celebrate = QtGui.QMovie( self.configs['celebrating_image_file']) self.move_celebrate.setScaledSize(self.label_celebrate.size()) self.playlist = QtMultimedia.QMediaPlaylist() self.playlist.addMedia( QtMultimedia.QMediaContent( QtCore.QUrl.fromLocalFile( self.configs['celebrating_sound_file']))) self.playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) self.sound_celebrate = QtMultimedia.QMediaPlayer() self.sound_celebrate.setPlaylist(self.playlist) self.sound_celebrate.setVolume(100) return
def __init__(self): super().__init__() self.setupUi(self) self.VOICE_INFO_URL = 'https://vtcc.ai/voice/api/tts/v1/rest/voices' self.TTS_URL = 'https://viettelgroup.ai/voice/api/tts/v1/rest/syn' self.STT_URL = 'https://vtcc.ai/voice/api/asr/v1/rest/decode_file' self.TOKEN = '67EYFswc7lE2qrBbRePZCFYYq68sQHr7mngHhf8i8rWXH-XSXmLnfV9Ko3QDWDp1' self.CERT_PATH = 'bin/wwwvtccai.crt' self.voice_info = None self.get_voice_info() self.play_button.clicked.connect(self.play_button_event) self.player = QtMultimedia.QMediaPlayer() self.playlist = QtMultimedia.QMediaPlaylist() self.player.setPlaylist(self.playlist) self.recorder = QtMultimedia.QAudioRecorder() self.recorder.audioSettings().setCodec('audio/pcm') self.recorder.audioSettings().setSampleRate(11025) self.recorder.audioSettings().setChannelCount(1) self.recorder.setContainerFormat('wav') record_file = QtCore.QUrl.fromLocalFile(getcwd() + '/temp/record.wav') self.recorder.setOutputLocation(record_file) self.record_button.clicked.connect(self.record_event)
def __init__(self, ddir, parent=None): super().__init__(parent) self.setGeometry(0, 0, col10, row10) self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_NoSystemBackground, True) self.ddir = ddir self.clips = [ "{}/{}".format(ddir, name) for name in os.listdir(str(ddir)) if name.endswith(".mp4") or name.endswith('.mkv') ] self.video_widget = QtMultimediaWidgets.QVideoWidget() self.video_widget.setGeometry(0, 0, col10, row10) self.player = QtMultimedia.QMediaPlayer() self.player.setVideoOutput(self.video_widget) layout = QVBoxLayout(self) layout.addWidget(self.video_widget) self.playlist = QtMultimedia.QMediaPlaylist() self.addMedia() self.playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) self.player.setPlaylist(self.playlist) self.timer = QTimer(self) self.timer.timeout.connect(self.check_videos) self.timer.start(10000)
def play(self, id): self.player = QtMultimedia.QMediaPlayer() self.playlist = QtMultimedia.QMediaPlaylist() self.player.setPlaylist(self.playlist) # Создание плеера и плейлиста для него icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap('pause.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ui.pushButton_2.setIcon(icon) # Смена иконки self.ui.pushButton_2.clicked.disconnect() self.ui.pushButton_2.clicked.connect(self.button_play_stop) # Назначение команд для кнопки for media in range(id, len(self.songs)): title, performer = self.songs[media][0], self.songs[media][1] downloaded_audio = os.listdir(path=f'{work_dir}/audio') # Получение списка скачанных аудио if media == id: self.ui.performer.setText(performer) self.ui.main_title.setText(title) # Назначение названия и автора первого воспроизводимого трека self.url = QtCore.QUrl.fromLocalFile( f'{work_dir}/audio/{title}.mp3') self.content = QtMultimedia.QMediaContent(self.url) self.playlist.addMedia(self.content) # Добавление трека в плейлист self.player.play() self.playlist.currentMediaChanged.connect( lambda: self.change_current_data(id + 1))
def playGame(self): global o keepPlaying = True app = QApplication(sys.argv) w = QWidget() w.showMaximized() w.setWindowTitle("Otakunator") l = QLabel(w) pixmap = QPixmap("homescreen.jpg") l.setPixmap(pixmap) l.move(400, -300) l.resize(10000, 1500) l.show() l2 = QLabel(w) pixmap = QPixmap("cloud3.png") l2.setPixmap(pixmap) l2.move(400, 50) l2.resize(700, 400) l2.setScaledContents(True) l2.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) l2.hide() simg = QtGui.QImage("background.png").scaled(w.maximumSize()) pallette = QtGui.QPalette() pallette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(simg)) w.setPalette(pallette) label = QLabel(w) label.move(110, 530) label.resize(900, 80) engine = pyttsx3.init() engine.setProperty('voice', engine.getProperty('voices')[0].id) engine.setProperty('rate', 200) engine.say( "Hello I am Otaah kunator. Think about a character fro Narutoverse and I will guess it. So, are you ready to challenge me" ) engine.runAndWait() btn = QPushButton(w) btn.setText("Next") btn.move(900, 840) btn.show() btn.clicked.connect(dialog) o = 0 while o == 0: QtCore.QCoreApplication.processEvents() o = 0 l.move(300, 100) btn.move(510, 600) l2.show() btn2 = QPushButton(w) btn3 = QPushButton(w) btn.setText("Yes") btn2.setText("No") btn3.setText("Maybe") btn.move(500, 500) btn2.move(500, 650) btn3.move(500, 800) btn.resize(510, 100) btn2.resize(510, 100) btn3.resize(510, 100) btn.setStyleSheet( 'QPushButton {background-color: #005296; color: white; font-size: 18pt; font-weight: bold} ' ) btn2.setStyleSheet( 'QPushButton {background-color: #0BB5FF; color: white; font-size: 18pt; font-weight: bold}' ) btn3.setStyleSheet( 'QPushButton {background-color: #AFC1DA; color: white; font-size: 18pt; font-weight: bold}' ) btn.show() btn2.show() btn3.show() simg = QtGui.QImage("background.png").scaled(w.size()) pallette = QtGui.QPalette() pallette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(simg)) w.setPalette(pallette) l.resize(300, 500) url = QtCore.QUrl.fromLocalFile("./narutos-theme-song.wav") content = M.QMediaContent(url) playlist = M.QMediaPlaylist() playlist.addMedia(content) url = QtCore.QUrl.fromLocalFile("./naruto-sad-music-instant.wav") content = M.QMediaContent(url) playlist.addMedia(content) playlist.setPlaybackMode(M.QMediaPlaylist.Loop) player = M.QMediaPlayer() player.setPlaylist(playlist) player.play() while keepPlaying: print("Welcome to 20 Questions!") q = self.game.getNextQuestion() print(q) pixmap = QPixmap("Akinator3.png") l.setPixmap(pixmap) l.setScaledContents(True) l.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) l.move(880, 100) l.resize(650, 900) l.show() label.move(500, -100) label.setScaledContents(True) label.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) label.resize(550, 600) label.setText(str(q)) label.setFont(QtGui.QFont("Times", 25, QtGui.QFont.Decorative)) label.setWordWrap(True) label.show() #engine = pyttsx3.init() #engine.say(str(q)) #engine.runAndWait() #engine.stop() btn.clicked.connect(dialog) btn2.clicked.connect(dialog1) btn3.clicked.connect(dialog2) while o == 0: QtCore.QCoreApplication.processEvents() url2 = QtCore.QUrl.fromLocalFile("./activation.wav") content2 = M.QMediaContent(url2) player2 = M.QMediaPlayer() player2.setMedia(content2) player2.play() answer = a self.game.answerQuestion(self.game.questionsUsed[0], answer) i = 0 pixmap = QPixmap("Akinator3.png") l.setPixmap(pixmap) while len(self.game.remainingFood) > 1 and i < 20: i += 1 o = 0 nextQ = self.game.getNextQuestion() label.setText(nextQ) if not nextQ: break data = [(name, self.game.likelihood[name]) for name in self.game.remainingFood] #print(data) print(nextQ) btn.clicked.connect(dialog) btn2.clicked.connect(dialog1) btn3.clicked.connect(dialog2) while o == 0: QtCore.QCoreApplication.processEvents() url2 = QtCore.QUrl.fromLocalFile("./activation.wav") content2 = M.QMediaContent(url2) player2 = M.QMediaPlayer() player2.setMedia(content2) player2.play() answer = a if answer == 0: l2.show() pixmap = QPixmap("Akinator2.png") l.setPixmap(pixmap) if answer == 1: l2.show() pixmap = QPixmap("Akinator3.png") l.setPixmap(pixmap) while answer == -1: print(nextQ) label.setText(nextQ) print( "Please answer with 'yes', 'no', 'sometimes', 'maybe', or 'unknown'." ) answer = self.game.convertAnswer(input()) self.game.answerQuestion(self.game.questionsUsed[i], answer) #selected = self.game.remainingFood[0] data = [(name, self.game.likelihood[name]) for name in self.game.remainingFood] selected = max(data, key=lambda item: item[1])[0] #print(data) pixmap = QPixmap(selected + ".png") l.setPixmap(pixmap) l.setScaledContents(True) l.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) label.setText("Are you thinking of " + selected + "?") btn.clicked.connect(dialog) btn2.clicked.connect(dialog1) btn3.clicked.connect(dialog2) o = 0 while o == 0: QtCore.QCoreApplication.processEvents() url2 = QtCore.QUrl.fromLocalFile("./activation.wav") content2 = M.QMediaContent(url2) player2 = M.QMediaPlayer() player2.setMedia(content2) player2.play() correct = a if correct == 0: print("Enter the name of the character you are thinking of:") text, okPressed = QInputDialog.getText(w, "Get text", "Your name:", QLineEdit.Normal, "") if okPressed and text != '': print(text) correctAnswer = text if correctAnswer not in list(self.game.answers) and len( self.game.questionsUsed) < len(self.game.questions): print("Please help me learn about", correctAnswer, "by answering a few more questions.") i2 = len(self.game.questionsUsed) nextQ = self.game.askAnotherQuestion() while nextQ != None: pixmap = QPixmap("Akinator3.png") l.setPixmap(pixmap) label.setText(nextQ) btn.clicked.connect(dialog) btn2.clicked.connect(dialog1) btn3.clicked.connect(dialog2) o = 0 while o == 0: QtCore.QCoreApplication.processEvents() answer = a print(nextQ) while answer == -1: print(nextQ) print( "Please answer with 'yes', 'no', 'sometimes', 'maybe', or 'unknown'." ) answer = self.game.convertAnswer(input()) self.game.answerQuestion(self.game.questionsUsed[i2], answer) nextQ = self.game.askAnotherQuestion() i2 += 1 self.game.updateWeights(correctAnswer) else: self.game.updateWeights(selected) self.game.resetGame() d = QMessageBox.question(w, "Otakunator", "Continue?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) answer = -1 if d == QMessageBox.Yes: answer = 1 else: answer = 0 if answer != 1: keepPlaying = False label.setText("")
def run(): app = QApplication(sys.argv) scene = QGraphicsScene() # adding scene background scene.setBackgroundBrush(QBrush(QImage('./imgs/background.png'))) player = Player() # add the item to the scene scene.addItem(player) # make player focusable player.setFlag(QGraphicsItem.ItemIsFocusable) player.setFocus() # add a view, widget(invisible) view = QGraphicsView(scene) view.setFixedSize(800, 600) # horizontal and vertical scroll bar has benn disabled view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scene.setSceneRect(0, 0, 800, 600) player.setPos(view.width() / 2 - player.pixmap().width() / 2, view.height() - player.pixmap().height()) view.show() global score score = Score() scene.addItem(score) global health health = Health() scene.addItem(health) # spawn enemies timer = QTimer() def spawn(): enemy = Enemy() scene.addItem(enemy) timer.timeout.connect(spawn) timer.start(1000) # play background music url = QUrl.fromLocalFile("./sounds/intro.ogg") media = M.QMediaContent(url) playlist = M.QMediaPlaylist() playlist.addMedia(media) playlist.setPlaybackMode(M.QMediaPlaylist.Loop) music = M.QMediaPlayer() music.setPlaylist(playlist) music.setVolume(10) music.play() # media = M.QMediaContent(url) # music = M.QMediaPlayer() # music.setMedia(media) # music.setVolume(20) # music.play() sys.exit(app.exec_())
def initUI(self): # INITIALIZATION # CREATE Video Background # create link to movie file movie_file = QtCore.QUrl.fromLocalFile( 'file: C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/' '3d video background 2.mp4') media = QtMultimedia.QMediaContent(movie_file) # create video widget self.videoWidget = QtMultimediaWidgets.QVideoWidget() self.setCentralWidget(self.videoWidget) # media player object (video widget goes in media player) self.mediaPlayer = QtMultimedia.QMediaPlayer( None, QtMultimedia.QMediaPlayer.VideoSurface) self.mediaPlayer.setVideoOutput(self.videoWidget) # video_playlist self.playlist = QtMultimedia.QMediaPlaylist() self.playlist.setCurrentIndex(0) self.playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) self.playlist.addMedia(media) # add content to media player self.mediaPlayer.setPlaylist(self.playlist) self.mediaPlayer.play() # Load and start background music self.music_link = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\Deadline background music.mp3' ) self.playlist_music = QtMultimedia.QMediaPlaylist() self.playlist_music.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) media2 = QtMultimedia.QMediaContent(self.music_link) self.playlist_music.addMedia(media2) self.backgroundMusic_player = QtMultimedia.QMediaPlayer( ) # create mediaplayer object self.backgroundMusic_player.setPlaylist( self.playlist_music) # set background music as the video_playlist self.backgroundMusic_player.setVolume(35) self.backgroundMusic_player.play() # play it # make dark panel background self.blacktile_label = QtWidgets.QLabel(self) self.blacktile_label.setGeometry(QtCore.QRect( 1313, 0, 601, 1080)) #(1380, 720, 875, 493)) self.blacktile_label.setFrameShadow(QtWidgets.QFrame.Raised) self.blacktile_label.setObjectName("black panel") # self.timer_label.setAutoFillBackground(True) self.blacktile_label.setStyleSheet( "border-image: url('C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/" "blue control console vertical.png');") self.blacktile_label.show() # make a label to display BF4 logo logo_font = QtGui.QFont() logo_font.setFamily("Agency FB") logo_font.setPointSize(26) self.logo_label = QtWidgets.QLabel(self) self.logo_label.setGeometry(QtCore.QRect(1400, 90, 425, 100)) self.logo_label.setFrameShadow(QtWidgets.QFrame.Raised) self.logo_label.setTextFormat(QtCore.Qt.AutoText) self.logo_label.setAlignment(QtCore.Qt.AlignCenter) self.logo_label.setLayoutDirection(QtCore.Qt.RightToLeft) self.logo_label.setText('Reinforcements Available') self.logo_label.setFont(logo_font) self.logo_label.setStyleSheet( "border-image: url('C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/" "title background 2.png'); background-color:black; color: rgb(136, 204, 241)" ) self.logo_label.show() # make a label to display timer countdown self.timer_label = QtWidgets.QLabel(self) self.timer_label.setGeometry(QtCore.QRect(1411, 720, 417, 271)) self.timer_label.setFrameShadow(QtWidgets.QFrame.Raised) self.timer_label.setStyleSheet( "border-image: url('C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/" "blue tile background pic.jpg'); color: rgb(136, 204, 241)") self.timer_label.show() font2 = QtGui.QFont() font2.setFamily("Agency FB") font2.setPointSize(38) self.timer_label.setFont(font2) self.timer_label.setTextFormat(QtCore.Qt.AutoText) self.timer_label.setObjectName("timerlabel") self.timer_label.setText('Awaiting Orders') self.timer_label.setAlignment(QtCore.Qt.AlignCenter) self.timer_label.setLayoutDirection(QtCore.Qt.RightToLeft) # Create UP and DOWN arrow buttons to manually adjust timer # TIMER DOWN BUTTON self.down_button = QtWidgets.QPushButton(self) self.down_button.setGeometry(QtCore.QRect(1747, 938, 30, 30)) # create size of icon downbutton_icon = QtGui.QIcon() downbutton_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/down arrow.png' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.down_button.setIcon(downbutton_icon) self.down_button.setIconSize(QtCore.QSize(30, 30)) self.down_button.setObjectName("down button") self.down_button.clicked.connect(self.down_button_click) # TIMER UP BUTTON self.up_button = QtWidgets.QPushButton(self) self.up_button.setGeometry(QtCore.QRect(1777, 938, 30, 30)) up_button_icon = QtGui.QIcon() up_button_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/up arrow rev.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.up_button.setIcon(up_button_icon) self.up_button.setIconSize(QtCore.QSize(30, 30)) self.up_button.setObjectName("up button") self.up_button.clicked.connect(self.up_button_click) # Create "Cancel Timer" Button cancel_font = QtGui.QFont() cancel_font.setFamily("Agency FB") cancel_font.setPointSize(12) self.cancel_button = QtWidgets.QPushButton(self) self.cancel_button.setFont(cancel_font) self.cancel_button.setGeometry(QtCore.QRect(1396, 980, 160, 30)) self.cancel_button.setText('Cancel Orders') self.cancel_button.setStyleSheet( 'color: rgb(136, 204, 241); background-color: black;') self.cancel_button.setDisabled(True) self.cancel_button.hide() self.cancel_button.clicked.connect(self.cancel_clicked) # CREATE MEDIAPLAYER OBJECTS FOR SOUND EFFECTS (menu clicks) # Timer down beep self.url_timeDown = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\sound effects\\timer down.mp3' ) self.timeDown = QtMultimedia.QMediaContent(self.url_timeDown) self.timeDown_player = QtMultimedia.QMediaPlayer() self.timeDown_player.setMedia(self.timeDown) # Timer up beep self.url_timeUp = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\sound effects\\timer up.mp3' ) self.timeUp = QtMultimedia.QMediaContent(self.url_timeUp) self.timeUp_player = QtMultimedia.QMediaPlayer() self.timeUp_player.setMedia(self.timeUp) # error sound self.url_error = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\sound effects\\error sound.mp3' ) self.error = QtMultimedia.QMediaContent(self.url_error) self.error_player = QtMultimedia.QMediaPlayer() self.error_player.setMedia(self.error) self.error_player.setVolume(18) # radio beep (button click confirmation) self.url_radio = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\sound effects\\double radio beep.wav' ) self.radio = QtMultimedia.QMediaContent(self.url_radio) self.radio_player = QtMultimedia.QMediaPlayer() self.radio_player.setMedia(self.radio) # self.radio_player.setVolume(100) # LOAD VEHICLE AUDIO (4 FILES PER VEHICLE) #1. Anti-Air self.url_AA1 = QtCore.QUrl.fromLocalFile( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/sound/riendly timers/friendly AA r/' 'friendly aa pt1.mp3') self.AA1 = QtMultimedia.QMediaContent(self.url_AA1) self.AA1_player = QtMultimedia.QMediaPlayer() self.AA1_player.setMedia(self.AA1) self.url_AA2 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\friendly AA r\\' 'friendly aa pt2.mp3') self.AA2 = QtMultimedia.QMediaContent(self.url_AA2) self.AA2_player = QtMultimedia.QMediaPlayer() self.AA2_player.setMedia(self.AA2) self.url_AA3 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\friendly AA r\\' 'friendly aa pt3.mp3') self.AA3 = QtMultimedia.QMediaContent(self.url_AA3) self.AA3_player = QtMultimedia.QMediaPlayer() self.AA3_player.setMedia(self.AA3) self.url_AA4 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\friendly AA r\\' 'friendly aa pt4.mp3') self.AA4 = QtMultimedia.QMediaContent(self.url_AA4) self.AA4_player = QtMultimedia.QMediaPlayer() self.AA4_player.setMedia(self.AA4) #2. Scout Helicopter self.url_sh1 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly scout helicopter\\scout helo pt1 rev.mp3') self.sh1 = QtMultimedia.QMediaContent(self.url_sh1) self.sh1_player = QtMultimedia.QMediaPlayer() self.sh1_player.setMedia(self.sh1) self.url_sh2 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly scout helicopter\\scout helo pt2.wav') self.sh2 = QtMultimedia.QMediaContent(self.url_sh2) self.sh2_player = QtMultimedia.QMediaPlayer() self.sh2_player.setMedia(self.sh2) self.url_sh3 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly scout helicopter\\scout helo pt3.wav') self.sh3 = QtMultimedia.QMediaContent(self.url_sh3) self.sh3_player = QtMultimedia.QMediaPlayer() self.sh3_player.setMedia(self.sh3) self.url_sh4 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly scout helicopter\\scout helo pt4.wav') self.sh4 = QtMultimedia.QMediaContent(self.url_sh4) self.sh4_player = QtMultimedia.QMediaPlayer() self.sh4_player.setMedia(self.sh4) #3. attack helicopter self.url_ah1 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly attack helicopter\\attack helo pt1.wav') self.ah1 = QtMultimedia.QMediaContent(self.url_ah1) self.ah1_player = QtMultimedia.QMediaPlayer() self.ah1_player.setMedia(self.ah1) self.url_ah2 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly attack helicopter\\attack helo pt2.wav') self.ah2 = QtMultimedia.QMediaContent(self.url_ah2) self.ah2_player = QtMultimedia.QMediaPlayer() self.ah2_player.setMedia(self.ah2) self.url_ah3 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly attack helicopter\\attack helo pt3.wav') self.ah3 = QtMultimedia.QMediaContent(self.url_ah3) self.ah3_player = QtMultimedia.QMediaPlayer() self.ah3_player.setMedia(self.ah3) self.url_ah4 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly attack helicopter\\attack helo pt4.wav') self.ah4 = QtMultimedia.QMediaContent(self.url_ah4) self.ah4_player = QtMultimedia.QMediaPlayer() self.ah4_player.setMedia(self.ah4) #4. Boat self.url_b1 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly attack boat\\boat pt1.wav') self.b1 = QtMultimedia.QMediaContent(self.url_b1) self.b1_player = QtMultimedia.QMediaPlayer() self.b1_player.setMedia(self.b1) self.url_b2 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly attack boat\\boat pt2.wav') self.b2 = QtMultimedia.QMediaContent(self.url_b2) self.b2_player = QtMultimedia.QMediaPlayer() self.b2_player.setMedia(self.b2) self.url_b3 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly attack boat\\boat pt3.wav') self.b3 = QtMultimedia.QMediaContent(self.url_b3) self.b3_player = QtMultimedia.QMediaPlayer() self.b3_player.setMedia(self.b3) self.url_b4 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly attack boat\\boat pt4.wav') self.b4 = QtMultimedia.QMediaContent(self.url_b4) self.b4_player = QtMultimedia.QMediaPlayer() self.b4_player.setMedia(self.b4) #5. Tank self.url_t1 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly tank timer\\tank pt1.wav') self.t1 = QtMultimedia.QMediaContent(self.url_t1) self.t1_player = QtMultimedia.QMediaPlayer() self.t1_player.setMedia(self.t1) self.url_t2 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly tank timer\\tank pt2.wav') self.t2 = QtMultimedia.QMediaContent(self.url_t2) self.t2_player = QtMultimedia.QMediaPlayer() self.t2_player.setMedia(self.t2) self.url_t3 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly tank timer\\tank pt3.wav') self.t3 = QtMultimedia.QMediaContent(self.url_t3) self.t3_player = QtMultimedia.QMediaPlayer() self.t3_player.setMedia(self.t3) self.url_t4 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly tank timer\\tank pt4.wav') self.t4 = QtMultimedia.QMediaContent(self.url_t4) self.t4_player = QtMultimedia.QMediaPlayer() self.t4_player.setMedia(self.t4) #6. LAV self.url_lav1 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly lav\\lav pt1.wav') self.lav1 = QtMultimedia.QMediaContent(self.url_lav1) self.lav1_player = QtMultimedia.QMediaPlayer() self.lav1_player.setMedia(self.lav1) self.url_lav2 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly lav\\lav pt2.wav') self.lav2 = QtMultimedia.QMediaContent(self.url_lav2) self.lav2_player = QtMultimedia.QMediaPlayer() self.lav2_player.setMedia(self.lav2) self.url_lav3 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly lav\\lav pt3.wav') self.lav3 = QtMultimedia.QMediaContent(self.url_lav3) self.lav3_player = QtMultimedia.QMediaPlayer() self.lav3_player.setMedia(self.lav3) self.url_lav4 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly lav\\lav pt4.wav') self.lav4 = QtMultimedia.QMediaContent(self.url_lav4) self.lav4_player = QtMultimedia.QMediaPlayer() self.lav4_player.setMedia(self.lav4) #7. Jet self.url_j1 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\friendly jet\\' 'jet pt1.wav') self.j1 = QtMultimedia.QMediaContent(self.url_j1) self.j1_player = QtMultimedia.QMediaPlayer() self.j1_player.setMedia(self.j1) self.url_j2 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\friendly jet\\' 'jet pt2.wav') self.j2 = QtMultimedia.QMediaContent(self.url_j2) self.j2_player = QtMultimedia.QMediaPlayer() self.j2_player.setMedia(self.j2) self.url_j3 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\friendly jet\\' 'jet pt3.wav') self.j3 = QtMultimedia.QMediaContent(self.url_j3) self.j3_player = QtMultimedia.QMediaPlayer() self.j3_player.setMedia(self.j3) self.url_j4 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\friendly jet\\' 'jet pt4.wav') self.j4 = QtMultimedia.QMediaContent(self.url_j4) self.j4_player = QtMultimedia.QMediaPlayer() self.j4_player.setMedia(self.j4) #8. Fighter Bomber self.url_fb1 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly fighter bomber\\fighter bomber pt1.wav') self.fb1 = QtMultimedia.QMediaContent(self.url_fb1) self.fb1_player = QtMultimedia.QMediaPlayer() self.fb1_player.setMedia(self.fb1) self.url_fb2 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly fighter bomber\\fighter bomber pt2.wav') self.fb2 = QtMultimedia.QMediaContent(self.url_fb2) self.fb2_player = QtMultimedia.QMediaPlayer() self.fb2_player.setMedia(self.fb2) self.url_fb3 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly fighter bomber\\fighter bomber pt3.wav') self.fb3 = QtMultimedia.QMediaContent(self.url_fb3) self.fb3_player = QtMultimedia.QMediaPlayer() self.fb3_player.setMedia(self.fb3) self.url_fb4 = QtCore.QUrl.fromLocalFile( 'C:\\Users\\Owner\\PycharmProjects\\BF4 Deployment Timer\\sound\\friendly timers\\' 'friendly fighter bomber\\fighter bomber pt4.wav') self.fb4 = QtMultimedia.QMediaContent(self.url_fb4) self.fb4_player = QtMultimedia.QMediaPlayer() self.fb4_player.setMedia(self.fb4) # End of audio file upload # CREATE VEHICLE BUTTONS #1. Anti Air self.AA_button = QtWidgets.QPushButton(self) # create AA button self.AA_button.setGeometry(QtCore.QRect(1450, 600, 146, 89)) # create size of icon self.AA_icon = QtGui.QIcon() # create an icon object self.AA_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/blue icons/AA blue.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) # give object a picture attribute self.AA_icon_green = QtGui.QIcon() self.AA_icon_green.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/green icons/AA green.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) # give it an green icon to switch to when pressed self.AA_button.setIcon(self.AA_icon) self.AA_button.setIconSize(QtCore.QSize(350, 350)) self.AA_button.setObjectName("AA_button") self.AA_button.clicked.connect( self.AA_click) # connect button to its click method self.AA_button.clicked.connect( self.timer_AA_start) # connect button to it's timer #2. Tank self.tank_button = QtWidgets.QPushButton(self) self.tank_button.setGeometry(QtCore.QRect(1450, 475, 146, 89)) self.tank_icon = QtGui.QIcon() self.tank_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/blue icons/tank blue.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tank_icon_green = QtGui.QIcon() self.tank_icon_green.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/green icons/tank green.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tank_button.setIcon(self.tank_icon) self.tank_button.setIconSize(QtCore.QSize(350, 350)) self.tank_button.setObjectName("tank_button") self.tank_button.clicked.connect(self.tank_click) self.tank_button.clicked.connect(self.timer_tank_start) #3. Jet self.jet_button = QtWidgets.QPushButton(self) self.jet_button.setGeometry(QtCore.QRect(1650, 225, 146, 89)) self.jet_icon = QtGui.QIcon() self.jet_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/blue icons/jet blue.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.jet_icon_green = QtGui.QIcon() self.jet_icon_green.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/green icons/jet green.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.jet_button.setIcon(self.jet_icon) self.jet_button.setIconSize(QtCore.QSize(350, 350)) self.jet_button.setObjectName("jet_button") self.jet_button.clicked.connect(self.jet_click) self.jet_button.clicked.connect(self.timer_jet_start) #4. Scout Helicopter self.scout_heli_button = QtWidgets.QPushButton(self) self.scout_heli_button.setGeometry(QtCore.QRect(1650, 350, 146, 89)) self.scout_heli_icon = QtGui.QIcon() self.scout_heli_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/blue icons/' 'scout heli blue.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.scout_heli_icon_green = QtGui.QIcon() self.scout_heli_icon_green.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/green icons/' 'scout heli green.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.scout_heli_button.setIcon(self.scout_heli_icon) self.scout_heli_button.setIconSize(QtCore.QSize(350, 350)) self.scout_heli_button.setObjectName("scout heli button") self.scout_heli_button.clicked.connect(self.scout_helo_click) self.scout_heli_button.clicked.connect(self.timer_scout_helo_start) #5. Boat self.boat_button = QtWidgets.QPushButton(self) self.boat_button.setGeometry(QtCore.QRect(1650, 600, 146, 89)) self.boat_icon = QtGui.QIcon() self.boat_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/blue icons/boat blue.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.boat_icon_green = QtGui.QIcon() self.boat_icon_green.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/green icons/boat green.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.boat_button.setIcon(self.boat_icon) self.boat_button.setIconSize(QtCore.QSize(350, 350)) self.boat_button.setObjectName("boat icon") self.boat_button.clicked.connect(self.boat_click) self.boat_button.clicked.connect(self.timer_boat_start) #6. LAV self.lav_button = QtWidgets.QPushButton(self) self.lav_button.setGeometry(QtCore.QRect(1650, 475, 146, 89)) self.lav_icon = QtGui.QIcon() self.lav_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/blue icons/lav blue.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.lav_icon_green = QtGui.QIcon() self.lav_icon_green.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/green icons/lav green.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.lav_button.setIcon(self.lav_icon) self.lav_button.setIconSize(QtCore.QSize(350, 350)) self.lav_button.setObjectName("LAV button") self.lav_button.clicked.connect(self.lav_click) self.lav_button.clicked.connect(self.timer_lav_start) #7. attack helo self.attack_helo_button = QtWidgets.QPushButton(self) self.attack_helo_button.setGeometry(QtCore.QRect(1450, 350, 146, 89)) self.attack_helo_icon = QtGui.QIcon() self.attack_helo_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/blue icons/' 'attack helo blue.jpg'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.attack_helo_icon_green = QtGui.QIcon() self.attack_helo_icon_green.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/green icons/' 'attack helo green.jpg'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.attack_helo_button.setIcon(self.attack_helo_icon) self.attack_helo_button.setIconSize(QtCore.QSize(350, 350)) self.attack_helo_button.setObjectName("attack helo icon") self.attack_helo_button.clicked.connect(self.attack_helo_click) self.attack_helo_button.clicked.connect(self.timer_attack_helo_start) #8. fighter bomber self.fighter_bomber_button = QtWidgets.QPushButton(self) self.fighter_bomber_button.setGeometry(QtCore.QRect( 1450, 225, 146, 89)) self.fighter_bomber_icon = QtGui.QIcon() self.fighter_bomber_icon.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/blue icons/bomber blue.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.fighter_bomber_icon_green = QtGui.QIcon() self.fighter_bomber_icon_green.addPixmap( QtGui.QPixmap( 'C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/images/vehicle icons/green icons/bomber green.jpg' ), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.fighter_bomber_button.setIcon(self.fighter_bomber_icon) self.fighter_bomber_button.setIconSize(QtCore.QSize(350, 350)) self.fighter_bomber_button.setObjectName("Fighter Bomber button") self.fighter_bomber_button.clicked.connect(self.fighter_bomber_click) self.fighter_bomber_button.clicked.connect( self.timer_fighter_bomber_start) # CREATE TIMERS (OBJECTS) FOR EACH VEHICLE #1. AA self.countdown_AA = QtCore.QTimer() self.countdown_AA.timeout.connect(self.print_timer) self.countdown_AA.timeout.connect(self.AA_click) #2. Scout Helo self.countdown_scout_helo = QtCore.QTimer() self.countdown_scout_helo.timeout.connect(self.print_timer) self.countdown_scout_helo.timeout.connect(self.scout_helo_click) #3. Attack Helo self.countdown_attack_helo = QtCore.QTimer() self.countdown_attack_helo.timeout.connect(self.print_timer) self.countdown_attack_helo.timeout.connect(self.attack_helo_click) #4. Boat self.countdown_boat = QtCore.QTimer() self.countdown_boat.timeout.connect(self.print_timer) self.countdown_boat.timeout.connect(self.boat_click) #5. Tank self.countdown_tank = QtCore.QTimer() self.countdown_tank.timeout.connect(self.print_timer) self.countdown_tank.timeout.connect(self.tank_click) #6. LAV self.countdown_lav = QtCore.QTimer() self.countdown_lav.timeout.connect(self.print_timer) self.countdown_lav.timeout.connect(self.lav_click) #7. Jet self.countdown_jet = QtCore.QTimer() self.countdown_jet.timeout.connect(self.print_timer) self.countdown_jet.timeout.connect(self.jet_click) #8. Fighter Bomber self.countdown_fighter_bomber = QtCore.QTimer() self.countdown_fighter_bomber.timeout.connect(self.print_timer) self.countdown_fighter_bomber.timeout.connect( self.fighter_bomber_click) # Create lists for buttons and timer objects. For loops will be used to reset default states of each. self.vehicle_audio_list = [ self.AA1_player, self.AA2_player, self.AA3_player, self.AA4_player, self.sh1_player, self.sh2_player, self.sh3_player, self.sh4_player, self.ah1_player, self.ah2_player, self.ah3_player, self.ah4_player, self.b1_player, self.b2_player, self.b3_player, self.b4_player, self.t1_player, self.t2_player, self.t3_player, self.t4_player, self.lav1_player, self.lav2_player, self.lav3_player, self.lav4_player, self.j1_player, self.j2_player, self.j3_player, self.j4_player, self.fb1_player, self.fb2_player, self.fb3_player, self.fb4_player ] self.timer_obj_list = [ self.countdown_AA, self.countdown_scout_helo, self.countdown_attack_helo, self.countdown_boat, self.countdown_tank, self.countdown_fighter_bomber, self.countdown_jet, self.countdown_lav ] # self.vehicle_button_list = [self.fighter_bomber_button, self.attack_helo_button, self.lav_button, # self.boat_button, self.scout_heli_button, self.jet_button, self.tank_button, # self.AA_button] # create dictionary pairing buttons and their default icons to make resetting to default easy self.button_icon_dict = { self.fighter_bomber_button: self.fighter_bomber_icon, self.attack_helo_button: self.attack_helo_icon, self.lav_button: self.lav_icon, self.boat_button: self.boat_icon, self.scout_heli_button: self.scout_heli_icon, self.jet_button: self.jet_icon, self.tank_button: self.tank_icon, self.AA_button: self.AA_icon, }
def extraSetup(self): # main window self.window = self.ui # Lists self.playlistView = self.window.Playlist self.recommendLocalListView = self.window.RecommendLocal self.recommendLocalListView.doubleClicked.connect( self.recommendLocalListViewDoubleClickHandler) # self.recommendOnlineListView = self.window.RecommendOnline # Song Info section self.posterView = self.window.PosterView self.songTitle = self.window.SongTitle self.songArtist = self.window.SongArtist self.songAlbum = self.window.SongAlbum # player Controls self.prevBtn = self.window.Prev self.nextBtn = self.window.Next self.stopBtn = self.window.Stop self.playPauseBtn = self.window.PlayPause # Volume Controls self.volumeDecr = self.window.VolumeDecr self.volumeIncr = self.window.VolumeIncr self.mute = self.window.Mute self.volumeText = self.window.VolumeLabel # player timeline controls self.progressBar = self.window.ProgressBar self.currentTime = self.window.CurrentTime self.totalTime = self.window.TotalTime # Menu bar items self.openFolder = self.window.actionOpen_Folder self.editMetadata = self.window.actionEdit_MetaData # self.fetchRecommendation = self.window.actionFetch_Recommendation self.aboutProject = self.window.actionAbout_Project self.seeSourceCode = self.window.actionSee_Source_on_Github self.reportBug = self.window.actionReport_Bug # set shortcuts on menu items self.openFolder.setShortcut('Ctrl+O') self.editMetadata.setShortcut('Ctrl+E') # self.fetchRecommendation.setShortcut('Ctrl+R') # add actions on menu items """ all events are triggered from here """ self.openFolder.triggered.connect(self.browseHandler) self.editMetadata.triggered.connect(self.editMetadataHandler) # media control handlers self.playPauseBtn.clicked.connect(self.playPauseHandler) self.stopBtn.clicked.connect(self.stopHandler) self.prevBtn.clicked.connect(self.prevHandler) self.nextBtn.clicked.connect(self.nextHandler) # volume control handlers self.volumeIncr.clicked.connect(self.volumeIncrHandler) self.volumeDecr.clicked.connect(self.VolumeDecrHandler) self.mute.clicked.connect(self.muteHandler) # open webpages self.aboutProject.triggered.connect(self.openAboutUrl) self.seeSourceCode.triggered.connect(self.openGitHubUrl) self.reportBug.triggered.connect(self.openIssuesUrl) # create music player items self.mediaPlayer = QtMultimedia.QMediaPlayer() self.mediaPlaylist = QtMultimedia.QMediaPlaylist() self.mediaPlayer.setPlaylist(self.mediaPlaylist) # settings , in Ini format self.settings = QtCore.QSettings(QtCore.QSettings.IniFormat, QtCore.QSettings.UserScope, const.orgName, const.projName) self.settings.setFallbacksEnabled(False) # print(dir(self.settings)) # read from settings and set volume # set songsFolder None so if we don't find it in settings we don't crawlFolder self.songsFolder = None self.loadSettings() # localStorage init self.manageLocalStorage = ManageLocalStorage(const.LS_connectionName) # recommendation Cache init # build Cache # self.manageCache.buildCache() # The playback volume is linear in effect and the value # can range from 0 - 100, values outside this range will be clamped. self.mediaPlayer.setVolume(int(self.volume)) self.mediaPlayer.positionChanged.connect( self.mediaPlayerPositionChangedHandler) self.mediaPlayer.durationChanged.connect(self.durationChangedHandler) self.mediaPlayer.volumeChanged.connect(self.volumeChangedHandler) self.mediaPlayer.currentMediaChanged.connect( self.currentMediaChangedHandler) # print(dir(self.mediaPlayer)) self.progressBar.sliderMoved.connect(self.seekPosition) self.progressBar.setTracking(True) self.sliderEventSender = QtWidgets.QSlider.sender(self.progressBar) # load music from songsFolder self.crawlFolder()
from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import Qt, QUrl from PyQt5 import QtMultimedia from .gui import MinesweeperApp from . import resources # noqa import sys import os if __name__ == '__main__': # For high DPI displays QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) app = QApplication(sys.argv) # This plays the background music in a continuous loop music_file = os.path.join(os.path.dirname(__file__), 'background.mp3') bgm_playlist = QtMultimedia.QMediaPlaylist() bgm_playlist.addMedia( QtMultimedia.QMediaContent(QUrl.fromLocalFile(music_file))) bgm_playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) bgm_player = QtMultimedia.QMediaPlayer() bgm_player.setPlaylist(bgm_playlist) bgm_player.play() window = MinesweeperApp() window.show() sys.exit(app.exec_())
# Show the scene # First the view widget gets the event, which sends it to the scene # The scene sends the event to the item in focus view = QGraphicsView(scene) view.setBackgroundBrush(QBrush(QImage("./res/images/background.png"))) view.setAttribute(Qt.WA_DeleteOnClose) view.setViewport(QGLWidget()) view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) view.setFixedSize(800, 600) scene.setSceneRect(0, 0, 800, 600) # set the end condition health.dead.connect(functools.partial(gameOver, app, view, scene)) # set the player position player.setPos(view.width() / 2, view.height() - player.pixmap().height()) # play the background music url = QUrl.fromLocalFile("./res/sounds/background.wav") media = M.QMediaContent(url) playlist = M.QMediaPlaylist() playlist.addMedia(media) playlist.setPlaybackMode(M.QMediaPlaylist.Loop) music = M.QMediaPlayer() music.setPlaylist(playlist) music.setVolume(10) music.play() view.show() sys.exit(app.exec_())
def setLeftWidget(self): self.left_media_label = QtWidgets.QLabel("左边") self.left_media_label.setStyleSheet(''' QWidget{ background-color:#3f7fFfFF; font-size:24px; font-weight:700; font-family:"Helvetica Neue", Helvetica, Arial, sans-serif; color:red; } ''') image = QtGui.QPixmap("./resource/mai-move.jpg") image = image.scaled(self.left_widght.width(), self.height(), QtCore.Qt.KeepAspectRatio) self.left_media_label.setPixmap(image) self.left_layout.addWidget(self.left_media_label, 0, 0, 1, 1, QtCore.Qt.AlignCenter) video_url = Video_URL[0] self.player = QtMultimedia.QMediaPlayer() self.player_widget = QtMultimediaWidgets.QVideoWidget() self.player_widget.setFixedSize(self.width() / 2, self.height()) self.left_layout.addWidget(self.player_widget, 0, 0, 1, 1, QtCore.Qt.AlignCenter) self.player.setVideoOutput(self.player_widget) # self.player.setMedia(QtMultimedia.QMediaContent(QtWidgets.QFileDialog.getOpenFileUrl()[0])) # self.player.setMedia(QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile("/Users/ianchang/Downloads/dance.mp4"))) # self.player.setMedia(QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(video_url))) self.playlist = QtMultimedia.QMediaPlaylist() self.playlist.addMedia( QtMultimedia.QMediaContent( QtCore.QUrl.fromLocalFile( "/Users/ianchang/Public/Git/Git_Hub/tf-openpose/etcs/dance.mp4" ))) self.playlist.addMedia( QtMultimedia.QMediaContent( QtCore.QUrl.fromLocalFile( "/Users/ianchang/Public/opencv-master/doc/js_tutorials/js_assets/cup.mp4" ))) self.playlist.addMedia( QtMultimedia.QMediaContent( QtCore.QUrl.fromLocalFile( "/Users/ianchang/Public/2018-08-06/ScreenTest/MI/123.mp4")) ) self.playlist.addMedia( QtMultimedia.QMediaContent( QtCore.QUrl.fromLocalFile( "/Users/ianchang/Public/2017-11-23/BAD8015AC2CE8184FD6451F7F856755B.mp4" ))) self.playlist.addMedia( QtMultimedia.QMediaContent( QtCore.QUrl.fromLocalFile( "/Users/ianchang/Public/Git/Git_Hub/cross/samples/Test_JS/Resources/image/abc.mp4" ))) self.playlist.addMedia( QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(video_url))) self.playlist.setPlaybackMode( QtMultimedia.QMediaPlaylist.CurrentItemInLoop) self.playlist.setCurrentIndex(0) self.player.setPlaylist(self.playlist) self.player.play()