-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
74 lines (54 loc) · 2.23 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import sys
import os
import re
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent
from pydub import AudioSegment
from youtube_dl import YoutubeDL
import numpy as np
from audio import NowPlayingWidget, YTMediaPlayer
from widgets.queue_widget import QueueWidget
from widgets.media_controls import MediaControls
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.init_ui()
def init_ui(self):
self.main_widget = QtWidgets.QWidget()
palette = QtGui.QPalette()
palette.setColor(QtGui.QPalette.Background, QtCore.Qt.white)
self.setAutoFillBackground(True)
self.setPalette(palette)
self.main_layout = QtWidgets.QVBoxLayout()
self.main_layout.setContentsMargins(0, 0, 0, 0)
self.main_layout.setSpacing(15)
with open('token.txt') as token_file:
key = token_file.read()
self.media_player = YTMediaPlayer(key)
self.view = NowPlayingWidget(self.media_player)
self.main_layout.addWidget(self.view)
self.container = QtWidgets.QVBoxLayout()
self.container.setContentsMargins(200, 0, 200, 0)
self.main_layout.addLayout(self.container)
self.queue_widget = QueueWidget(self.media_player)
self.container.addWidget(self.queue_widget)
self.main_layout.addStretch()
self.controls = MediaControls(self.media_player)
self.main_layout.addWidget(self.controls)
self.main_widget.setLayout(self.main_layout)
self.setCentralWidget(self.main_widget)
self.setWindowIcon(QtGui.QIcon('images/logo.png'))
self.setWindowTitle('Milk Player')
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_P:
self.media_player.query('eminem lucky you')
self.media_player.query('Lucky Luke FEEL Bass Boosted')
if __name__ == '__main__':
app_id = 'me.ravenkls.milkplayer.one'
if sys.platform == 'win32':
import ctypes
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
app = QtWidgets.QApplication([])
window = MainWindow()
window.show()
sys.exit(app.exec_())